Monday, 15 October 2012

Microsoft Hotfix/KB Check

Created the below for a requirement installed check in CM 2012, based on the script here:

Option Explicit
On Error Resume Next
Dim strComputer, objWMIService, colQuickFixes, objQuickFix, HFInstalled, HFID
strComputer = "."
HFID = "KB958830"
HFInstalled = False
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colQuickFixes = objWMIService.ExecQuery ("Select * from Win32_QuickFixEngineering")
For Each objQuickFix in colQuickFixes
  If objQuickFix.HotFixID = HFID Then
      HFInstalled = True
      Exit For
   End If
If HFInstalled = True Then
    wScript.Quit 0
    wScript.Quit 1
End If

No comments:

Post a Comment