ivan Posted August 12, 2006 Posted August 12, 2006 (edited) I'm trying to help a friend who is not a programmer with a script mostly using scriptomatic output. The script works fine on my xp system, but on his windows 2000 the object generated from the query is empty...This is an extract from the code.Local $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") Local $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_PnPEntity where DeviceID like 'USB\\%'")Since I don't have windows2000, i've had to install autoit on his pc, sit in his office for a few hours to check out what could be going wrong. Since I didn't have anything at my disposal, I snooped his registry to see if a key was present in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WBEM\Scripting, and found the correct Default Namespace to be root\CIMV2.I also thought it could have been $strComputer, so I tried setting it to 'localhost', '127.0.0.1', '.', @ComputerName .... and it did not save me from the embarassment!!!!!!!Local $strComputer = "localhost" So, now i'm back on my xp, and unless I want to install windows 2000 here, i've got to return to his office sometime soon with a working solution.Here is the extract of the part of the script that doesn't work on his windows2000. It's been severely modified from the orignial just so I can pinpoint the problem.expandcollapse popup$Device = "Vid_0c88&Pid_fe43" $DeviceOutput = DiagnoseUSBPnPEntity($Device ) if $DeviceOutput=0 then MsgBox(0, 'Diagnostic', 'nothing found') else MsgBox(0, 'Diagnostic', $DeviceOutput ) endif Func DiagnoseUSBPnPEntity($pDevice) Local $strComputer = "localhost" Local $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") Local $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_PnPEntity where DeviceID like 'USB\\%'") Dim $Log[1] Local $LogVar = "" Local $RetVal = 0 If IsObj($colItems) Then ;;;;;;;;;; TEST LINE BELOW successful msgbox(0,'test', 'OBJ OK') ;;;;;;;;;; TEST END For $objItem In $colItems ;;;;;;;;;; TEST LINE BELOW FAILED $objItem IS EMPTY ON WINDOWS 2000 msgbox(0,'test', 'got here') ;;;;;;;;;; TEST END $LogVar = "" $LogVar = LogIt("Availability: " & $objItem.Availability, "just log me", $LogVar) $LogVar = LogIt("Caption: " & $objItem.Caption, "just log me", $LogVar) $LogVar = LogIt("Class Guid: " & $objItem.ClassGuid, "just log me", $LogVar) $LogVar = LogIt("Config Manager Error Code: " & $objItem.ConfigManagerErrorCode, "just log me", $LogVar) $LogVar = LogIt("Config Manager User Config: " & $objItem.ConfigManagerUserConfig, "just log me", $LogVar) $LogVar = LogIt("Creation Class Name: " & $objItem.CreationClassName, "just log me", $LogVar) $LogVar = LogIt("Description: " & $objItem.Description, "just log me", $LogVar) $LogVar = LogIt("Device ID: " & $objItem.DeviceID, "just log me", $LogVar) $LogVar = LogIt("Error Cleared: " & $objItem.ErrorCleared, "just log me", $LogVar) $LogVar = LogIt("Error Description: " & $objItem.ErrorDescription, "just log me", $LogVar) $LogVar = LogIt("Install Date: " & $objItem.InstallDate, "just log me", $LogVar) $LogVar = LogIt("Last Error Code: " & $objItem.LastErrorCode, "just log me", $LogVar) $LogVar = LogIt("Manufacturer: " & $objItem.Manufacturer, "just log me", $LogVar) $LogVar = LogIt("Name: " & $objItem.Name, "just log me", $LogVar) $LogVar = LogIt("PNP Device ID: " & $objItem.PNPDeviceID, "just log me", $LogVar) $z = $objItem.PowerManagementCapabilities If Not IsObj($z) Then $a = 1 Else For $x In $z $LogVar = LogIt("Power Management Capabilities: " & $x, "just log me", $LogVar) $LogVar = LogIt("Power Management Supported: " & $objItem.PowerManagementSupported, "just log me", $LogVar) $LogVar = LogIt("Service: " & $objItem.Service, "just log me", $LogVar) $LogVar = LogIt("Status: " & $objItem.Status, "just log me", $LogVar) $LogVar = LogIt("Status Info: " & $objItem.StatusInfo, "just log me", $LogVar) $LogVar = LogIt("System Creation Class Name: " & $objItem.SystemCreationClassName, "just log me", $LogVar) $LogVar = LogIt("System Name: " & $objItem.SystemName, "just log me", $LogVar) Next EndIf $LogVar = StringStripWS($LogVar, 2) If StringInStr($LogVar, $pDevice) Then $RetVal = $LogVar EndIf _ArrayAdd($Log, $LogVar) Next EndIf $Log[0] = Int(UBound($Log) - 1) Return $RetVal EndFunc ;==>DiagnoseUSBPnPEntityPS: by the way, i did check out msdn for wmi system requirements. Windows2000 is compliant according to the following page Edited August 12, 2006 by ivan Think out of the boxGrabber: Yet another WinInfo tool_CSVLib (still alpha)Dynamic html in au3
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now