Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for cdplayer.bat

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

  1. @ECHO OFF
  2. :: For Windows NT only
  3. VER | FIND "Windows NT" >NUL
  4. IF ERRORLEVEL 1 GOTO Syntax
  5.  
  6. :: Use local environment
  7. SETLOCAL
  8.  
  9. :: Check command line parameter
  10. ECHO.%* | FIND "?" >NUL
  11. IF NOT ERRORLEVEL 1 GOTO Syntax
  12.  
  13. :: Find all registry sub-keys of HKEY_LOCAL_MACHINE\SYSTEM\DISK
  14. REGEDIT /E %TEMP%.\CDROM1.REG "HKEY_LOCAL_MACHINE\SYSTEM\DISK"
  15.  
  16. :: Find the CD-ROM drive
  17. FOR /F "tokens=2 delims==" %%A IN ('TYPE %TEMP%.\CDROM1.REG ^| FIND /I "\\Device\\CdRom"') DO SET CDAudio=%%A
  18. SET CDAudio=%CDAudio:"=%
  19.  
  20. :: Delete the temporary .REG file
  21. DEL %TEMP%.\CDROM1.REG
  22.  
  23. :: Select the track
  24. SET Track=%1
  25. IF %Track%0 LSS 100 (SET Track=0%Track%) ELSE (SET Track=%Track%)
  26. IF EXIST "%CDAudio%\Track%Track%.cda" (
  27. 	SET Play="%CDAudio%\Track%Track%.cda"
  28. ) ELSE (
  29. 	ECHO.
  30. 	ECHO Track%Track% not found on CD in drive %CDAudio%
  31. 	ECHO Playing all tracks instead
  32. 	SET Play="%CDAudio%"
  33. )
  34.  
  35. :: Start the player
  36. START "CD Audio" CDPLAYER.EXE -play %Play%
  37.  
  38. :: Done
  39. ENDLOCAL
  40. GOTO End
  41.  
  42. :Syntax
  43. ECHO.
  44. ECHO CDPlayer.bat,  Version 1.00 for Windows NT 4
  45. ECHO Play audio CD or track(s)
  46. ECHO.
  47. ECHO Written by Rob van der Woude
  48. ECHO http://www.robvanderwoude.com
  49. ECHO.
  50. ECHO Usage:  CDPLAYER  [ track_number ]
  51.  
  52. :End
  53.  

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