Jump to content
Sign in to follow this  

windows 2000 scriptomatic empty objects

Recommended Posts

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', '', '.', @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.

$Device = "Vid_0c88&Pid_fe43" 
$DeviceOutput = DiagnoseUSBPnPEntity($Device )

if $DeviceOutput=0 then
MsgBox(0, 'Diagnostic', 'nothing found')
MsgBox(0, 'Diagnostic', $DeviceOutput )

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
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
            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)
         $LogVar = StringStripWS($LogVar, 2)
         If StringInStr($LogVar, $pDevice) Then
            $RetVal = $LogVar
         _ArrayAdd($Log, $LogVar)
   $Log[0] = Int(UBound($Log) - 1)
   Return $RetVal
EndFunc   ;==>DiagnoseUSBPnPEntity

PS: by the way, i did check out msdn for wmi system requirements. Windows2000 is compliant according to the following page

Edited by ivan

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...