Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for removables.bat

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

  1. :: DETECTOR OF REMOVABLE DEVICES [V5.0c Final] author Carlitos.dll
  2. :: carlitosdll.blogspot.com
  3. :: Tested in Windows 2000 and XP. Doesn't work in Windows 98 and ME.
  4.  
  5. @ECHO OFF
  6. IF NOT "%OS%"=="Windows_NT" GOTO Other
  7.  
  8. ECHO Mounted removable devices detected
  9. ECHO.----------------------------------
  10.  
  11. VER | FIND "NT"   >NUL && GOTO NT2000
  12. VER | FIND "2000" >NUL && GOTO NT2000
  13.  
  14. :XPVISTASEVEN
  15. FOR /F "tokens=3 delims=\:" %%A IN ('REG Query HKLM\SYSTEM\MountedDevices ^| FIND "530054004F00520041"') DO (
  16. 	DIR /A %%A:\ >NUL 2>&1 && ECHO.%%A:
  17. )
  18. GOTO:EOF
  19.  
  20. :NT2000
  21. START /WAIT REGEDIT /E "%Temp%\devices.dat" "HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices"
  22. FOR /F "tokens=3 delims=\:" %%A IN ('TYPE "%Temp%\devices.dat" ^| FINDSTR /R /B /I /C:"\"\\\\DosDevices\\\\[A-Z]:\"=hex:.*,53,00,54,00,4f,00,52,00,41"') DO (
  23. 	DIR /A %%A:\ >NUL 2>&1 && ECHO.%%A:
  24. )
  25. DEL /F /Q "%Temp%\devices.dat" >NUL 2>&1
  26. GOTO:EOF
  27.  
  28. :Other
  29. ECHO Current batch is not supported in this Operating System version.
  30.  

page last uploaded: 2017-08-21, 14:26