Once again, building upon my previous post, Determine if an Update has been Installed or Not, I transformed my initial IsQuickFixNoInstalled() function into a more versatile function to list all the updates installed. One could easily use it to populate a listbox or output its results to a text file for easier review.
'---------------------------------------------------------------------------------------
' Procedure : EnumerateQuickFixes
' Author : Daniel Pineault, CARDA Consultants Inc.
' Website : http://www.cardaconsultants.com
' Purpose : Enumerate the updates installed on the specified PC
' Copyright : The following may be altered and reused as you wish so long as the
' copyright notice is left unchanged (including Author, Website and
' Copyright). It may not be sold/resold or reposted on other sites (links
' back to this site are allowed).
'
' Input Variables:
' ~~~~~~~~~~~~~~~~
' sHost : Name, IP address of the computer to check
' Omit this input variable if checking the local PC
'
' Usage:
' ~~~~~~
' ? EnumerateQuickFixes
' ? EnumerateQuickFixes("172.12.243.195")
'
' Revision History:
' Rev Date(yyyy/mm/dd) Description
' **************************************************************************************
' 1 2011-07-22 Initial Release
'---------------------------------------------------------------------------------------
Public Function EnumerateQuickFixes(Optional sHost As String = ".") As Boolean
'only seems to report on Windows updates and nothing else (ie not office updates)
'Ref: https://msdn.microsoft.com/en-us/library/aa394391(v=vs.85).aspx
On Error GoTo Error_Handler
Dim oWMI As Object 'WMI object to query about the PC's OS
Dim sWMIQuery As String 'WMI Query
Dim oQuickFixes As Object 'List of QuickFixes matching our WMI Query
Dim oQuickFix As Object 'Individual QuickFix
Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & sHost & "\root\cimv2")
sWMIQuery = "SELECT * " & _
"FROM Win32_QuickFixEngineering"
Set oQuickFixes = oWMI.ExecQuery(sWMIQuery)
For Each oQuickFix In oQuickFixes
Debug.Print oQuickFix.HotFixID, oQuickFix.Description, oQuickFix.Caption, oQuickFix.InstalledOn ', oQuickFix.InstallDate, oQuickFix.Name, oQuickFix.Status
Next
Error_Handler_Exit:
On Error Resume Next
Set oQuickFix = Nothing
Set oQuickFixes = Nothing
Set oWMI = Nothing
Exit Function
Error_Handler:
MsgBox "The following error has occurred" & vbCrLf & vbCrLf & _
"Error Number: " & Err.Number & vbCrLf & _
"Error Source: EnumerateQuickFixes" & vbCrLf & _
"Error Description: " & Err.Description & _
Switch(Erl = 0, "", Erl <> 0, vbCrLf & "Line No: " & Erl) _
, vbOKOnly + vbCritical, "An Error has Occurred!"
Resume Error_Handler_Exit
End Function
Do note that the function takes a couple seconds to return a value.