Option Explicit Dim arrOperations, arrResultCodes Dim blnFilterKB Dim colHistory, objHistory, objSearcher Dim strFilterKB, strMsg, strUpd ' Arrays to convert result numbers to their descriptions arrResultCodes = Array( "not started", "in progress", "succeeded", _ "succeeded with errors", "failed", "aborted" ) arrOperations = Array( "", "Installation", "Uninstallation" ) blnFilterKB = False strMsg = "" ' Parse the command line arguments With WScript.Arguments If .Named.Count > 1 Then Syntax If .Unnamed.Count > 1 Then Syntax If .Named.Exists( "KB" ) Then blnFilterKB = True strFilterKB = .Named.Item( "KB" ) If Trim( strFilterKB ) = "" Then If .Unnamed.Count = 1 Then strFilterKB = .Unnamed(0) Else blnFilterKB = False End If End If Else If .Named.Count > 0 Then Syntax End If If .Named.Count = 0 And .Unnamed.Count = 1 Then blnFilterKB = True strFilterKB = .Unnamed(0) If UCase( Left( strFilterKB, 2 ) ) = "KB" Then strFilterKB = Mid( strFilterKB, 3 ) End If End If End With If blnFilterKB And Not IsNumeric( strFilterKB ) Then Syntax ' Create a Windows Update Searcher object Set objSearcher = CreateObject( "Microsoft.Update.Searcher" ) ' Query the complete history With objSearcher Set colHistory = .QueryHistory( 0, .GetTotalHistoryCount - 1 ) End With ' Loop through the stored history, and format the results For Each objHistory In colHistory With objHistory strUpd = "Title : " & .Title & vbCrLf _ & "Description : " & .Description & vbCrLf _ & "Update ID : " & .UpdateIdentity.UpdateID _ & ", Rev. " & .UpdateIdentity.RevisionNumber & vbCrLf _ & "Support URL : " & .SupportUrl & vbCrLf _ & "Date : " & .Date & vbCrLf _ & "Result : " & arrOperations( .Operation ) _ & " " & arrResultCodes( .ResultCode ) & vbCrLf & vbCrLf If blnFilterKB Then If InStr( 1, .Title, "KB" & strFilterKB, vbTextCompare ) Then strMsg = strMsg & strUpd End If Else strMsg = strMsg & strUpd End If End With Next ' Display the end result WScript.Echo strMsg ' Done Set colHistory = Nothing Set objSearcher = Nothing Sub Syntax strMsg = vbCrLf _ & WScript.ScriptName & ", Version 1.00" _ & vbCrLf _ & "List or query Windows Update history" _ & vbCrLf & vbCrLf _ & "Usage: " & UCase( WScript.ScriptName ) & " [ KBnumber | /KB:number ]" _ & vbCrLf & vbCrLf _ & "Where: ""(KB)number"" is the Microsoft Knowledge Base number you want to" _ & vbCrLf _ & " query for (default is to list the complete history)" _ & vbCrLf & vbCrLf _ & "Written by Rob van der Woude" _ & vbCrLf _ & "http://www.robvanderwoude.com" WScript.Echo strMsg WScript.Quit 1 End Sub