(view source code of cdrom.bat as plain text)
@ECHO OFF
REM * * * * * * * * * * * * * * * * * * * * * * * * * * * *
REM * CDROM.BAT, Version 1.00 *
REM * Read the CD-ROM drive letter from Win9x's registry *
REM * Written by Rob van der Woude *
REM * *
REM * Sorry, for Windows 95 and 98 only. *
REM * *
REM * Inspired by Tom Lavedas' batch file with the same *
REM * functionality, which was adapted by Bill James, I *
REM * added a second pass through the registry to skip *
REM * a ZIP drive. *
REM * The CHOICE trick to strip the square brackets from *
REM * the registry entry's name came from "Outsider". *
REM * *
REM * Thanks, guys. *
REM * * * * * * * * * * * * * * * * * * * * * * * * * * * *
REM * * * * * * * * * *
REM * Recursive calls *
REM * * * * * * * * * *
IF "%1"=="Environment" GOTO Environment
IF "%1"=="Loop" GOTO Loop
REM * * * * * * * * * * * * * * * * * * * * * * * *
REM * Make sure there is enough environment space *
REM * * * * * * * * * * * * * * * * * * * * * * * *
%COMSPEC% /E:2048 /C %0 Environment
SET CMDLINE=
CALL %TEMP%.\CDROM1.BAT
GOTO Cleanup
:Environment
REM * * * * * * * * * *
REM * Reset variables *
REM * * * * * * * * * *
SET CDROM=
SET KEY=
REM * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
REM * Find all registry sub-keys of HKEY_LOCAL_MACHINE\Enum\SCSI *
REM * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
START /W REGEDIT /E %TEMP%.\CDROM1.REG "HKEY_LOCAL_MACHINE\Enum\SCSI"
REM * * * * * * * * * * * * * * * * * * * * * * * * * * * *
REM * Extract the registry sub-key that is NOT the ZIP *
REM * drive and store it in the environment variable KEY *
REM * * * * * * * * * * * * * * * * * * * * * * * * * * * *
TYPE %TEMP%.\CDROM1.REG|FIND "["|FIND /V "_ZIP"|FIND /V "SCSI]"|FIND /V "&">%TEMP%.\CDROM1.TMP
ECHO.>>%TEMP%.\CDROM1.TMP
TYPE %TEMP%.\CDROM1.TMP|DATE|FIND "):"|FIND "[">%TEMP%.\CDROM1.BAT
REM * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
REM * Temporary batch files VOER.BAT and TYP.BAT are for Dutch Win9x *
REM * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
ECHO SET KEY=%%6>VOER.BAT
ECHO SET KEY=%%4>TYP.BAT
ECHO SET KEY=%%3>CURRENT.BAT
CALL %TEMP%.\CDROM1.BAT
REM * * * * * * * * * * * * * * * * * * * * * * * * * * * *
REM * Strip the square brackets [] from the KEY variable *
REM * * * * * * * * * * * * * * * * * * * * * * * * * * * *
ECHO ]|CHOICE /C:%KEY%; %0 Loop >%TEMP%.\CDROM1.BAT
SET KEY=
CALL %TEMP%.\CDROM1.BAT
GOTO End
:Second
REM * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
REM * Find all registry sub-keys of the registry entry found earlier *
REM * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
START /W REGEDIT /E %TEMP%.\CDROM1.REG "%KEY%"
REM * * * * * * * * * * * * * * * * * * * * * * *
REM * Check if this really is the CD-ROM entry *
REM * * * * * * * * * * * * * * * * * * * * * * *
TYPE %TEMP%.\CDROM1.REG|FIND "Class"|FIND "CDROM">NUL
IF ERRORLEVEL 1 GOTO NoCdRom
REM * * * * * * * * * * * * * * * * * * * * * * * *
REM * Read the drive letter assignment and store *
REM * store it in the environment variable CDROM *
REM * * * * * * * * * * * * * * * * * * * * * * * *
TYPE %TEMP%.\CDROM1.REG|FIND "CurrentDriveLetterAssignment">%TEMP%.\CDROM1.TMP
ECHO.>> %TEMP%.\CDROM1.TMP
TYPE %TEMP%.\CDROM1.TMP|DATE|FIND "):"|FIND "Assignment">%TEMP%.\CDROM1.BAT
REM * * * * * * * * * * * * * * * * * * * * * * * *
REM * Make sure there is enough environment space *
REM * * * * * * * * * * * * * * * * * * * * * * * *
SET KEY=
SET CMDLINE=
REM * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
REM * Temporary batch files VOER.BAT and TYP.BAT are for Dutch Win9x *
REM * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
ECHO SET CDROM=%%7>VOER.BAT
ECHO SET CDROM=%%5>TYP.BAT
ECHO SET CDROM=%%4>CURRENT.BAT
CALL %TEMP%.\CDROM1.BAT
REM * * * * * * * * * * * * * * * * * *
REM * If variable not set, aparently *
REM * no CD-ROM drive was detected *
REM * * * * * * * * * * * * * * * * * *
IF "%CDROM%"=="" GOTO NoCdRom
REM * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
REM * Strip double quotes "" from the CDROM variable and create *
REM * a temporary batch file to change the master environment *
REM * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
ECHO @ECHO OFF>%TEMP%.\CDROM1.BAT
FOR %%A IN (%CDROM%) DO ECHO SET CDROM=%%A:>>%TEMP%.\CDROM1.BAT
CALL %TEMP%.\CDROM1.BAT
REM * * * * * * * * * * * *
REM * Display the result *
REM * * * * * * * * * * * *
ECHO CD-ROM drive detected, drive letter assigned is %CDROM%
GOTO End
:NoCdRom
REM * * * * * * * * * * * *
REM * Display the result *
REM * * * * * * * * * * * *
ECHO No CD-ROM drive detected
GOTO End
:Loop
REM * * * * * * * * * * * * * * * * * * * * * * * * * * * *
REM * Strip the square brackets [] from the KEY variable *
REM * * * * * * * * * * * * * * * * * * * * * * * * * * * *
SHIFT
IF "%1"=="]" GOTO Second
IF NOT "%1"=="[[" SET KEY=%KEY%%1
GOTO Loop
:Cleanup
REM * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
REM * Clean up the ugly mess in the TEMP directory and the environment *
REM * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
SET KEY=
SET CMDLINE=
IF EXIST CURRENT.BAT DEL CURRENT.BAT
IF EXIST TYP.BAT DEL TYP.BAT
IF EXIST VOER.BAT DEL VOER.BAT
IF EXIST %TEMP%.\CDROM1.* DEL %TEMP%.\CDROM1.*
:End
page last modified: 2024-04-16; loaded in 0.0071 seconds