WMI Write Text File Errors

  • Thread starter Thread starter whiggins
  • Start date Start date
W

whiggins

Hello, I am trying to gather some patch information for several machines and
I wrote a little vbscript to gather the information for me. I am having some
problems writing our to a text file. The issue I am having is that when it
goes to write a line that has no information it gives me an error of
Microsoft VBScript runtime error: Object required.

If have tested to see if the variables are empty string, Nulls, and Nothing.
The script works fine if I just do a Wscript.Echo instead of writing it out
to a file.

Any Help would be greatly appreciated.
Thanks in advance.

Here is my script
Dim Name, Description, Status, HotFix
Name = ""
Description = ""
Status = ""
HotFix = ""
Set objFS = WScript.CreateObject("Scripting.FileSystemObject")
Set strPatchResults = objFS.createtextfile("C:\Temp\PatchTemp.txt", true)
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM
Win32_QuickFixEngineering",,48)
For Each objItem in colItems
Name = ""
Description = ""
Status = ""
HotFix = ""
Name = objItem.Name
Description = objItem.Description
Status = objItem.Status
HotFix = objItem.HotFixID
If Name = "" Then
Name = "N/A"
End If
If Description = "" Then
Description = "N/A"
End If
If Status = "" Then
Status = "Installed"
End if
If HotFix = "" Then
HotFix = "N/A"
End If
strPatchResults.WriteLine(Name)
strPatchResults.WriteLine(Description)
strPatchResults.WriteLine(Status)
strPatchResults.WriteLine(HotFix)
PatchCount = PatchCount + 1
Next
strPatchResults.Close()
 
Back
Top