(view source code of cdactxp.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
:: Localize variable and enable delayed variable expansion
SETLOCAL ENABLEDELAYEDEXPANSION
SET CDACT=
SET Multi=
:: The actual command
FOR /F "tokens=3" %%A IN ('ECHO list volume ^| DISKPART.EXE ^| FIND.EXE " CDFS "') DO (
IF DEFINED CDROM (
SET CDACT=!CDACT! %%A
SET Multi=s
) ELSE (
SET CDACT=%%A
)
)
:: Display the result
IF DEFINED CDACT (
ECHO CD/DVD found in drive%Multi% %CDACT%
) ELSE (
ECHO No CDs/DVDs found in any drive
)
:: Done
ENDLOCAL & SET CDACT=%CDACT%
GOTO:EOF
:Syntax
ECHO CDACTXP.BAT, Version 1.00 for Windows XP
ECHO Find all CD/DVD-ROM drives containing a CD/DVD-ROM using Windows' DISKPART
ECHO.
ECHO Usage: CDACTXP
ECHO.
ECHO A list of all CD/DVD-ROM drives actually containing a disk will be
ECHO stored in the environment variable CDACT.
ECHO This batch file will fail if any non-CD/DVD volume is labeled "CDFS".
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.0079 seconds