Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for scsi.bat

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

  1. @ECHO OFF
  2. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  3. VER | FIND "Windows NT" >NUL
  4. IF NOT ERRORLEVEL 1 GOTO Syntax
  5. IF NOT [%1]==[] GOTO Syntax
  6.  
  7. SETLOCAL
  8. REGEDIT /E "%Temp%.\SCSI.REG" "HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\Scsi"
  9. FOR /F "tokens=3 delims=] " %%A IN ('TYPE "%Temp%.\SCSI.REG" ^| EGREP -i "\[HKEY_LOCAL_MACHINE\\HARDWARE\\DEVICEMAP\\Scsi\\Scsi Port [0-9]+\]"') DO CALL :EnumBus Port %%A
  10. DEL "%Temp%.\SCSI.REG"
  11. ENDLOCAL
  12. GOTO:EOF
  13.  
  14. :EnumBus
  15. FOR /F "tokens=5 delims=] " %%K IN ('TYPE "%Temp%.\SCSI.REG" ^| EGREP -i "\[HKEY_LOCAL_MACHINE\\HARDWARE\\DEVICEMAP\\Scsi\\Scsi Port %2\\Scsi Bus [0-9]+\]"') DO CALL :EnumId Port %2 Bus %%K
  16. GOTO:EOF
  17.  
  18. :EnumId
  19. FOR /F "tokens=7 delims=] " %%X IN ('TYPE "%Temp%.\SCSI.REG" ^| EGREP -i "\[HKEY_LOCAL_MACHINE\\HARDWARE\\DEVICEMAP\\Scsi\\Scsi Port %2\\Scsi Bus %4\\Target Id [0-9]+\]"') DO CALL :DriveType Port %2 Bus %4 ID %%X
  20. GOTO:EOF
  21.  
  22. :DriveType
  23. REGEDIT /E "%Temp%.\SCSIDRV.REG" "HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\Scsi\Scsi Port %2\Scsi Bus %4\Target Id %6"
  24. FOR /F "tokens=1* delims==" %%A IN ('TYPE "%Temp%.\SCSIDRV.REG"') DO SET %%~A=%%~B
  25. DEL "%Temp%.\SCSIDRV.REG"
  26. IF "%Type%"=="CdRomPeripheral" (
  27. 	ECHO SCSI Port %2, Bus %4, ID %6, %DeviceName%=%Identifier%
  28. ) ELSE (
  29. 	ECHO SCSI Port %2, Bus %4, ID %6, %Type%=%Identifier%
  30. )
  31. GOTO:EOF
  32.  
  33. :Syntax
  34. ECHO.
  35. ECHO SCSI.bat,  Version 1.10 for Windows 2000 / XP
  36. ECHO Enumerate SCSI drives
  37. ECHO.
  38. ECHO Usage:  SCSI
  39. ECHO.
  40. ECHO Uses EGREP.EXE, available at
  41. ECHO http://unxutils.sourceforge.net/
  42. ECHO.
  43. ECHO Written by Rob van der Woude
  44. ECHO http://www.robvanderwoude.com
  45.  

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