Powered by GeSHi

Source code for getcdromdrives.bat

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

  1. @ECHO OFF
  2. :: Check Windows version and command line arguments (none required)
  3. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  4. IF NOT  "%~1"==""           GOTO Syntax
  5.  
  6. :: Remove drive letters no longer in use
  7. MOUNTVOL /R
  8.  
  9. :: Read the list of physical drives from the registry, and show only the CDROM drives
  10. FOR /F "tokens=2 delims=\ " %%A IN ('REG Query "HKLM\SYSTEM\MountedDevices" /v "\DosDevices\*" ^| FINDSTR /R /E /C:" 5C[0-9A-F]*"') DO ECHO.%%A
  11. GOTO:EOF
  12.  
  13. :Syntax
  14. ECHO.
  15. ECHO GetCDROMDrives.bat,  Version 1.00 for Windows 7 and later
  16. ECHO List all CDROM drives on the local computer
  17. ECHO.
  18. ECHO Usage:   GETCDROMDRIVES
  19. ECHO.
  20. ECHO Written by Rob van der Woude
  21. ECHO http://www.robvanderwoude.com
  22.