Win32_Product collection returning NULL

C

Carl29464

I am trying to get a collection of installed software. My script works
for SOME computers and not others. (ALL ARE WINXPSP2). For those that
do not work, I can change the script and successfully get a list of
SERVICES running on the machine so WMI must be working.

What can cause the Win32_Services to work and the Win32_Product
collection to NOT work?

===================================================================
On Error Resume Next
Dim colSoftware
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

'strComputer = InputBox ("Enter Machine Name")
strComputer = "SAC-WK-COL-LMB"
' strNameSpace = InputBox ("Enter Name Space")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\Root
\cimv2")


If Err = 0 Then
MsgBox "Connection Successful"

Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Product",
"WQL",wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
wscript.echo objItem.Name & ";" _
& objItem.Vendor & ";" _
& Mid(objItem.InstallDate, 5, 2) _
& Mid(objItem.InstallDate, 7, 2) _
& Mid(objItem.InstallDate, 1, 4) & VBCRLF
Next


ElseIf Err <> 0 Then

MsgBox "An Error Was Encountered", 16, "Error" & VBCr _

MsgBox "Machine Name: " & UCase(strComputer) & VBCr _
& "Error Number: " & Err.Number & VBCr _
& "Description: " & Err.Description & VBCr _
& "Source: " & Err.Source

End If
Err.Clear
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top