Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for cdromxp.bat

(view source code of cdromxp.bat as plain text)

  1. @ECHO OFF
  2. :: Check Windows version and command line arguments
  3. IF NOT "%OS%"=="Windows_NT"  GOTO Syntax
  4. IF NOT "%~1"==""             GOTO Syntax
  5. DISKPART.EXE /? >NUL 2>&1 || GOTO Syntax
  6.  
  7. :: The actual command is a one liner
  8. FOR /F "tokens=3" %%A IN ('ECHO list volume ^| DISKPART.EXE ^| FIND.EXE "-ROM "') DO SET CDROM=%%A:
  9.  
  10. :: Display the result
  11. SET CDROM
  12.  
  13. :: Done
  14. GOTO:EOF
  15.  
  16. :Syntax
  17. ECHO CDROMXP.BAT,  Version 1.00 for Windows XP
  18. ECHO Read the CD-ROM drive letter using Windows' DISKPART utility
  19. ECHO.
  20. ECHO Usage:  CDROMXP
  21. ECHO.
  22. ECHO The last CD-ROM drive letter will be stored in the environment variable CDROM.
  23. ECHO This batch file may fail if any disk volume label ends with "-ROM".
  24. ECHO.
  25. ECHO Written by Rob van der Woude
  26. ECHO http://www.robvanderwoude.com
  27.  
  28. :: Done
  29. IF "%OS%"=="Windows_NT" GOTO:EOF
  30.  

page last modified: 2024-04-16; loaded in 0.0046 seconds