Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for scsi2.bat

(view source code of scsi2.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. IF EXIST "%Temp%.\SCSI.REG" DEL "%Temp%.\SCSI.REG"
  9. START /WAIT REGEDIT /E "%Temp%.\SCSI.REG" "HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\Scsi"
  10. FOR /F "tokens=7,10-14 delims=]\ " %%A in ('TYPE "%Temp%.\SCSI.REG"') DO IF /I "%%C %%D"=="Target Id" IF "%%F"=="" CALL :DriveType Port %%A Bus %%B ID %%E
  11. IF EXIST "%Temp%.\SCSI.REG" DEL "%Temp%.\SCSI.REG"
  12. IF EXIST "%Temp%.\SCDR.REG" DEL "%Temp%.\SCDR.REG"
  13. ENDLOCAL
  14. GOTO:EOF
  15.  
  16. :DriveType
  17. IF EXIST "%Temp%.\SCDR.REG" DEL "%Temp%.\SCDR.REG"
  18. START /WAIT REGEDIT /E "%Temp%.\SCDR.REG" "HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\Scsi\Scsi Port %2\Scsi Bus %4\Target Id %6"
  19. IF NOT EXIST "%Temp%.\SCDR.REG" GOTO:EOF
  20. FOR /F "tokens=1* delims==" %%A IN ('TYPE "%Temp%.\SCDR.REG"') DO SET %%~A=%%~B
  21. IF "%Type%"=="CdRomPeripheral" (
  22. 	ECHO SCSI Port %2, Bus %4, ID %6, %DeviceName%=%Identifier%
  23. ) ELSE (
  24. 	ECHO SCSI Port %2, Bus %4, ID %6, %Type%=%Identifier%
  25. )
  26. GOTO:EOF
  27.  
  28. :Syntax
  29. ECHO.
  30. ECHO SCSI.bat,  Version 2.10 for Windows 2000 / XP
  31. ECHO Enumerate SCSI drives
  32. ECHO.
  33. ECHO Usage:  SCSI  [ /? ]
  34. ECHO.
  35. ECHO Written by Rob van der Woude
  36. ECHO http://www.robvanderwoude.com
  37.  

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