Hello,
I tried to write a script to enumerate the installed software on a Windows 2003 Server. However, I keep getting the error (null): 0x80041010 from the WMI class Win32_Product. The script works fine on my XP workstation and Windows 2000 Server machines.
My code is listed below:
strComputer = "."
arrSoftware = EnumSoftware(strComputer)
For Each objItem In arrSoftware
Wscript.Echo objItem
Next
Private Function EnumSoftware(ByVal strComputer)
Dim objDicData, objWMIService, colItems, objItem
Set objDicData = CreateObject("Scripting.Dictionary")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Product")
For Each objItem In colItems
If Not objDicData.Exists(objItem.Caption) Then
objDicData.Add objItem.Caption, objItem.Caption & vbTab & objItem.Version
End If
Next
EnumSoftware = objDicData.Items
Set objWMIService = Nothing: Set colItems = Nothing
End Function
I get the WMI error at the line "For Each objItem In colItems" in the the For Loop in the function.
I would appreciate it if anyone can point me to the right direction on how to correct this problem.
Thanks!
CluM09
I tried to write a script to enumerate the installed software on a Windows 2003 Server. However, I keep getting the error (null): 0x80041010 from the WMI class Win32_Product. The script works fine on my XP workstation and Windows 2000 Server machines.
My code is listed below:
strComputer = "."
arrSoftware = EnumSoftware(strComputer)
For Each objItem In arrSoftware
Wscript.Echo objItem
Next
Private Function EnumSoftware(ByVal strComputer)
Dim objDicData, objWMIService, colItems, objItem
Set objDicData = CreateObject("Scripting.Dictionary")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Product")
For Each objItem In colItems
If Not objDicData.Exists(objItem.Caption) Then
objDicData.Add objItem.Caption, objItem.Caption & vbTab & objItem.Version
End If
Next
EnumSoftware = objDicData.Items
Set objWMIService = Nothing: Set colItems = Nothing
End Function
I get the WMI error at the line "For Each objItem In colItems" in the the For Loop in the function.
I would appreciate it if anyone can point me to the right direction on how to correct this problem.
Thanks!
CluM09