/* SCSI.rex */ /* List all SCSI and IDE drives */ /* Empty line */ Say /* Check command line arguments (none required) */ If Arg( 1, "E" ) Then Call Syntax /* Check OS version */ Parse Upper Source os . If os <> "WIN32" Then Call Syntax "This Rexx script was not written for this Windows version" /* Initialize W32Funcs */ If RxFuncAdd( "w32loadfuncs", "W32Util", "w32loadfuncs" ) Then Do Call Syntax "Could not load W32Util Rexx extension" End Else Do Call w32loadfuncs End /* Read SCSI ports from registry */ porthandle = w32RegOpenKey( "HKEY_LOCAL_MACHINE", "HARDWARE\DEVICEMAP\Scsi" ) If w32RegEnumKey( porthandle, , "port." ) Then Call Syntax Do i = 1 To port.0 Parse Upper Value port.i With test1 test2 port If test1||" "||test2 = "SCSI PORT" Then Do Call ScsiPort port.i, i End Else Do Call Syntax "Invalid port name: "||port.i End End Call w32RegCloseKey porthandle /* Done */ Exit 0 ScsiBus: Procedure port = Arg(1) bus = Arg(2) type = Arg(3) /* Read target ID from registry */ tidhandle = w32RegOpenKey( "HKEY_LOCAL_MACHINE", "HARDWARE\DEVICEMAP\Scsi\"||port||"\"||bus ) If w32RegEnumKey( tidhandle, , "tid." ) = 0 Then Do Do i = 1 To tid.0 Parse Upper Value tid.i With test1 test2 . If test1||" "||test2 = "TARGET ID" Then Do Call ScsiTid port, bus, tid.i, type End End End Call w32RegCloseKey tidhandle Return ScsiLId: procedure port = Arg(1) bus = Arg(2) tid = Arg(3) lid = Arg(4) type = Arg(5) /* Read logical ID from registry */ idhandle = w32RegOpenKey( "HKEY_LOCAL_MACHINE", "HARDWARE\DEVICEMAP\Scsi\"||port||"\"||bus||"\"||tid||"\"||lid ) identifier = w32RegQueryValue( idhandle, "Identifier" ) devtype = w32RegQueryValue( idhandle, "Type" ) If devtype = "CdRomPeripheral" Then Do devicename = w32RegQueryValue( idhandle, "DeviceName" ) End Else Do devicename = devtype End Call w32RegCloseKey idhandle id = SubStr( tid, 11 ) Say port||", "||bus||", ID "||id||", "||type||", "||devicename||" = "||identifier Return ScsiPort: Procedure port = Arg(1) /* Read SCSI bus from registry */ bushandle = w32RegOpenKey( "HKEY_LOCAL_MACHINE", "HARDWARE\DEVICEMAP\Scsi\"||port ) bustype = w32RegQueryValue( bushandle, "Driver" ) If Translate( bustype ) = "ATAPI" Then Do bustype = "IDE" End Else Do bustype = "SCSI" End If w32RegEnumKey( bushandle, , "bus." ) Then Call Syntax Do i = 1 To bus.0 Call ScsiBus port, bus.i, bustype End Call w32RegCloseKey bushandle Return ScsiTId: procedure port = Arg(1) bus = Arg(2) tid = Arg(3) type = Arg(4) /* Read logical ID from registry */ lidhandle = w32RegOpenKey( "HKEY_LOCAL_MACHINE", "HARDWARE\DEVICEMAP\Scsi\"||port||"\"||bus||"\"||tid ) If w32RegEnumKey( lidhandle, , "lid." ) = 0 Then Do Do i = 1 To lid.0 Parse Upper Value lid.i With test1 test2 test3 . If test1||" "||test2||" "||test3 = "LOGICAL UNIT ID" Then Do Call ScsiLid port, bus, tid, lid.i, type End End End Call w32RegCloseKey lidhandle Return Syntax: Parse Arg errdescr If errdescr <> "" Then Do Say errdescr Say End Say "SCSI.rex, Version 1.00 for Windows 2000" Say "Enumerate SCSI and IDE drives" Say Say "Usage: REGINA.EXE SCSI.REX [ /? ]" Say Say "Written by Rob van der Woude" Say "http://www.robvanderwoude.com" Exit 1 Return