Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for drives.bat

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

  1. @ECHO OFF
  2. :: Check Windows version and command line arguments
  3. VER | FIND "Windows 2000" >NUL
  4. IF ERRORLEVEL 1 GOTO Syntax
  5. IF NOT [%1]==[] IF /I NOT [%1]==[/F] IF /I NOT [%1]==[/R] GOTO Syntax
  6. IF NOT [%2]==[] GOTO Syntax
  7.  
  8. :: Export registry data to temporary file
  9. START /WAIT REGEDIT /E "%Temp%.\_drives.dat" "HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices"
  10. ECHO.
  11.  
  12. :: Read data from temporary file
  13. FOR /F "tokens=3,5 delims=\:," %%A IN ('TYPE "%Temp%.\_drives.dat" ^| FIND /I "\\DosDevices\\" ^| SORT') DO IF 0x%%~B LSS 0x60 (
  14. 	IF /I NOT [%1]==[/F] ECHO %%A:	Removable
  15. ) ELSE (
  16. 	IF /I NOT [%1]==[/R] ECHO %%A:	Fixed
  17. )
  18.  
  19. :: Remove temporary file
  20. IF EXIST "%Temp%.\_drives.dat" DEL "%Temp%.\_drives.dat"
  21.  
  22. :: Done
  23. GOTO:EOF
  24.  
  25.  
  26. :Syntax
  27. ECHO.
  28. ECHO Drives.bat,  Version 1.01 for Windows 2000
  29. ECHO Display local drives plus types
  30. ECHO.
  31. ECHO Usage:  DRIVES  [ /type ]
  32. ECHO.
  33. ECHO Where:  /type   may be either /F to display Fixed disks only,
  34. ECHO                            or /R to display Removable disks only
  35. ECHO.
  36. ECHO Note:   Removable drives that aren't currently available may still be displayed
  37. ECHO.
  38. ECHO Written by Rob van der Woude
  39. ECHO http://www.robvanderwoude.com
  40.  

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