(view source code of cdromxp.bat as plain text)
@ECHO OFF
:: Check Windows version and command line arguments
IF NOT "%OS%"=="Windows_NT" GOTO Syntax
IF NOT "%~1"=="" GOTO Syntax
DISKPART.EXE /? >NUL 2>&1 || GOTO Syntax
:: The actual command is a one liner
FOR /F "tokens=3" %%A IN ('ECHO list volume ^| DISKPART.EXE ^| FIND.EXE "-ROM "') DO SET CDROM=%%A:
:: Display the result
SET CDROM
:: Done
GOTO:EOF
:Syntax
ECHO CDROMXP.BAT, Version 1.00 for Windows XP
ECHO Read the CD-ROM drive letter using Windows' DISKPART utility
ECHO.
ECHO Usage: CDROMXP
ECHO.
ECHO The last CD-ROM drive letter will be stored in the environment variable CDROM.
ECHO This batch file may fail if any disk volume label ends with "-ROM".
ECHO.
ECHO Written by Rob van der Woude
ECHO http://www.robvanderwoude.com
:: Done
IF "%OS%"=="Windows_NT" GOTO:EOF
page last modified: 2024-04-16; loaded in 0.0046 seconds