cancel
Showing results for 
Search instead for 
Did you mean: 

Win2000, script to identify driver version...

sdo
Moderator
Moderator
Partner    VIP    Certified
Env: NBU ES v5.1 MP6, MSCS Win2000 SP4 cluster, SSO, 16 x LTO1.

Does anyone know how to identify which driver version is allocated to each tape drive device?

I can list the devices, and some basic details, but "driver" (name or number etc...) is not an attribute of the Win32_TapeDrive object.

Here's the VBScript that I have so far:



Option Explicit
Call s_main()
WScript.Quit

Sub s_main()
Dim lo_wmi, lc_tapes, lo_tape
Set lo_wmi = GetObject( "winmgmts:" )
Set lc_tapes = lo_wmi.InstancesOf( "Win32_TapeDrive" )
If lc_tapes.Count = 0 Then
WScript.Echo "No tape drives are installed on this computer."
Else
WScript.Echo "Count: " & lc_tapes.Count
For Each lo_tape In lc_tapes
WScript.Echo "=============================================="
Wscript.Echo "Availability: " & lo_tape.Availability
Wscript.Echo "Device ID: " & lo_tape.DeviceID
Wscript.Echo "Features High: " & lo_tape.FeaturesHigh
Wscript.Echo "Features Low: " & lo_tape.FeaturesLow
Wscript.Echo "Name: " & lo_tape.Name
Wscript.Echo "Needs Cleaning: " & lo_tape.NeedsCleaning
Wscript.Echo "Status: " & lo_tape.Status
Next
WScript.Echo "=============================================="
End If
End Sub
2 REPLIES 2

Dan_Lynch
Level 3
WMI often falls short in these types of tasks...
In pure WMI it is not possible I believe to get the Tape Symbolic Name - you could do wmi remote registry I suppose, but it would be messy.
One way could be the following - mind you there is no exception handling in this skeleton:

'
'TapeDriveVers.vbs
'run cscript.exe TapeDriveVers.vbs

strComputer = "NB01"

call getTapeDriveVers(strComputer)


function getTapeDriveVers(strComputer)

set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

wqlStr = "SELECT * FROM Win32_TapeDrive "

set objTapeCol = objWMI.ExecQuery(wqlStr,,48)
for each objTape in objTapeCol

txtDevID = replace(objTape.DeviceID, "\", "\\")
wqlStr2 = "ASSOCIATORS OF {Win32_PnPEntity.DeviceID=""" & txtDevID & """} " & _
"WHERE AssocClass=Win32_CIMLogicalDeviceCIMDataFile " & _
"Role=Antecedent ResultRole=Dependent "
set objDriver = objWMI.ExecQuery(wqlStr2,,48)

for each obj in objDriver
wscript.echo objTape.DeviceID & ", " & obj.FileName & ", " & obj.Version
next

next

end function

sdo
Moderator
Moderator
Partner    VIP    Certified
Hi Dan,
Thankyou so much for that. I would never have worked that out.
Here's a working script for anyone else. (Watch out for word/line wrap).
Regards,
Dave.





Option Explicit
Dim go_wmi
Set go_wmi = GetObject( "WinMgmts:" )
Call s_main()
WScript.Quit


Sub s_main()
Dim lc_tapes, lo_tape
Set lc_tapes = go_wmi.InstancesOf( "Win32_TapeDrive" )
If lc_tapes.Count = 0 Then
WScript.Echo "No tape drives are installed on this computer."
Else
WScript.Echo "Count: " & lc_tapes.Count
For Each lo_tape In lc_tapes
WScript.Echo "=============================================="
Wscript.Echo "Availability: " & lo_tape.Availability
Wscript.Echo "Device ID: " & lo_tape.DeviceID
Wscript.Echo "Features High: " & lo_tape.FeaturesHigh
Wscript.Echo "Features Low: " & lo_tape.FeaturesLow
Wscript.Echo "Name: " & lo_tape.Name
Wscript.Echo "Needs Cleaning: " & lo_tape.NeedsCleaning
Wscript.Echo "Status: " & lo_tape.Status
Call s_drivers( lo_tape.DeviceID )
Next
WScript.Echo "=============================================="
End If
End Sub



Sub s_drivers( ps_device_id )
Dim ls_device_id, ls_wql, lc_drivers, lo_driver
ls_device_id = Replace( ps_device_id, "\", "\\" )
ls_wql = "ASSOCIATORS OF {Win32_PnPEntity.DeviceID=""" & ls_device_id & """} " & _
"WHERE AssocClass=Win32_CIMLogicalDeviceCIMDataFile " & _
"Role=Antecedent ResultRole=Dependent "
Set lc_drivers = go_wmi.ExecQuery( ls_wql, ,48 )
For Each lo_driver In lc_drivers
Wscript.Echo "Driver: `" & lo_driver.FileName & "`, version `" & lo_driver.Version & "`"
Next
End Sub