Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for scsi.kix

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

  1. If $Help
  2. 	? "SCSI.kix,  Version 1.00 for Windows 2000"
  3. 	? "Enumerate SCSI drives" ?
  4. 	? "Usage:  KIX32.EXE  SCSI.KIX  [ $$Help=1 ]" ?
  5. 	? "Written by Rob van der Woude"
  6. 	? "http://www.robvanderwoude.com" ?
  7. 	Quit 1
  8. EndIf
  9.  
  10. Break Off
  11.  
  12. $Index1 = 0
  13. Do
  14. 	$PortName = EnumKey( "HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\Scsi\", $Index1 )
  15. 	If @ERROR = 0
  16. 		$x = ScsiPort( $PortName )
  17. 	EndIf
  18. 	$Index1 = $Index1 + 1
  19. Until @ERROR
  20.  
  21. ?
  22. ? "Press any key..."
  23. Get $Key
  24.  
  25. Function ScsiPort( $Port )
  26. 	$Index2 = 0
  27. 	Do
  28. 		$BusName = EnumKey( "HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\Scsi\$Port\", $Index2 )
  29. 		If @ERROR = 0
  30. 			$BusType = ReadValue( "HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\Scsi\$Port", "Driver" )
  31. 			If $BusType = atapi
  32. 				$BusType = "IDE"
  33. 			Else
  34. 				$BusType = "SCSI"
  35. 			EndIf
  36. 			$x = ScsiBus( $Port, $BusName, $BusType )
  37. 		EndIf
  38. 		$Index2 = $Index2 + 1
  39. 	Until @ERROR
  40. EndFunction
  41.  
  42.  
  43. Function ScsiBus( $Port, $Bus, $BusType )
  44. 	$Index3 = 0
  45. 	Do
  46. 		$TIdName = EnumKey( "HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\Scsi\$Port\$Bus\", $Index3 )
  47. 		If @ERROR = 0
  48. 			If InStr( $TIdName, "Target Id" )
  49. 				$x = ScsiTId( $Port, $Bus, $TIdName, $BusType )
  50. 			EndIf
  51. 		EndIf
  52. 		$Index3 = $Index3 + 1
  53. 	Until @ERROR
  54. EndFunction
  55.  
  56.  
  57. Function ScsiTId( $Port, $Bus, $TId, $BusType )
  58. 	$Index4 = 0
  59. 	Do
  60. 		$LIdName = EnumKey( "HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\Scsi\$Port\$Bus\$TId\", $Index4 )
  61. 		If @ERROR = 0
  62. 			If InStr( $LIdName, "Logical Unit Id" )
  63. 				$x = ScsiLId( $Port, $Bus, $TId, $LIdName, $BusType )
  64. 			EndIf
  65. 		EndIf
  66. 		$Index4 = $Index4 + 1
  67. 	Until @ERROR
  68. EndFunction
  69.  
  70.  
  71. Function ScsiLId( $Port, $Bus, $TId, $LId, $BusType )
  72. 	$Identifier = ReadValue( "HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\Scsi\$Port\$Bus\$TId\$LId", "Identifier" )
  73. 	$DevType    = ReadValue( "HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\Scsi\$Port\$Bus\$TId\$LId", "Type" )
  74. 	If $DevType = "CdRomPeripheral"
  75. 		$DeviceName = ReadValue( "HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\Scsi\$Port\$Bus\$TId\$LId", "DeviceName" )
  76. 	Else
  77. 		$DeviceName = $DevType
  78. 	EndIf
  79. 	$Id = SubStr( $Tid, 11 )
  80. 	? "$Port, $Bus, ID $Id, $BusType, $DeviceName = $Identifier"
  81. EndFunction
  82.  

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