"View Installation History" for WU5 without using the WU Web site

From: Torgeir Bakken \(MVP\) (Torgeir.Bakken-spam_at_hydro.com)
Date: 08/12/04


Date: Thu, 12 Aug 2004 23:41:39 +0200

Hi

Below is a VBScript that extracts information about installed updates
and present them in Notepad. Will only work for updates installed
using WU5 technology.

Put the script in a text file with file extension .vbs (e.g.
WU_History.vbs)

Tested on Windows XP SP2 only.

Example on output:

Report run at 12.08.2004 21:33:40
------------------------------------------------------------------
Title: Update for Windows XP HighMAT Support in CD Writing Wizard (KB831240)
Description: This extension allows you to create HighMAT CDs of your digital photos,
                     music, and videos optimized for viewing on consumer electronic devices
                     and player software. (snip)
Date/Time in GMT: 11.08.2004 11:34:51
Install mechanism: WindowsUpdate
Install status: Succeeded
------------------------------------------------------------------
Title: Microsoft Windows Journal Viewer (Windows XP)
Description: This accessory allows people who do not have a computer running Windows
                     XP Tablet PC Edition to view files that were created in Microsoft
                     Windows Journal on a Tablet PC.
Date/Time in GMT: 11.08.2004 11:34:41
Install mechanism: WindowsUpdate
Install status: Succeeded
------------------------------------------------------------------

Total number of updates found: 2
Number of updates succeeded: 2
Number of updates failed: 0
Number of updates aborted: 0

Here is the script:

'--------------------8<----------------------
' Script that reports installed updates that are
' installed with Windows Update v5 technology
'
' Result will be written to %temp%\UpdateHistory.txt
' and then launched in Notepad
'
' Author: Torgeir Bakken
' Date 2004-08-12
'
Option Explicit

Const OverwriteIfExist = -1
Const OpenAsASCII = 0

Dim oWU, iTHCount, colUpdate, oUpdate, sStatus, iTotal
Dim iSuccess, iFailed, iAborted, iUnknown, sErrorCode
Dim oFSO, oShell, sFile, f

On Error Resume Next
Set oWU = CreateObject("Microsoft.Update.Searcher")

If Err.Number <> 0 Then
   MsgBox "WU5 programming interface does not exist.", _
          vbInformation + vbSystemModal, "Update history"
   WScript.Quit
End If
On Error Goto 0

iTHCount = oWU.GetTotalHistoryCount
If iTHCount > 0 Then

   Set oFSO = CreateObject("Scripting.FileSystemObject")
   Set oShell = CreateObject("Wscript.Shell")
   sFile = oShell.ExpandEnvironmentStrings("%TEMP%") & "\UpdateHistory.txt"
   Set f = oFSO.CreateTextFile(sFile, _
                      OverwriteIfExist, OpenAsASCII)

   iTotal = 0
   iSuccess = 0
   iFailed = 0
   iAborted = 0
   iUnknown = 0

   f.WriteLine "Report run at " & Now
     f.WriteLine "---------------------------------" _
           & "---------------------------------"

   Set colUpdate = oWU.QueryHistory(0, iTHCount)

   For Each oUpdate In colUpdate
     f.WriteLine "Title:" & vbTab & vbTab & vbTab & oUpdate.Title
     f.WriteLine "Description:" & vbTab & vbTab & oUpdate.Description
     f.WriteLine "Date/Time in GMT:" & vbTab & oUpdate.Date
     f.WriteLine "Install mechanism:" & vbTab & oUpdate.ClientApplicationID

     sErrorCode = ""
     Select Case oUpdate.ResultCode
       Case 2
         sStatus = "Succeeded"
         iSuccess = iSuccess + 1
       Case 4
         sStatus = "Failed"
         iFailed = iFailed + 1
         sErrorCode = oUpdate.UnmappedResultCode
       Case 5
         sStatus = "Aborted"
         iAborted = iAborted + 1
       Case Else
         sStatus = "Unknown"
         iUnknown = iUnknown + 1
     End Select

     If sStatus = "Failed" Then
       f.WriteLine "Install error:" & vbTab & vbTab & sErrorCode
     End If

     f.WriteLine "Install status:" & vbTab & vbTab & sStatus
     f.WriteLine "---------------------------------" _
           & "---------------------------------"

     iTotal = iTotal + 1
   Next

   f.WriteLine
   f.WriteLine "Total number of updates found: " & iTotal
   f.WriteLine "Number of updates succeeded: " & iSuccess
   f.WriteLine "Number of updates failed: " & iFailed
   f.WriteLine "Number of updates aborted: " & iAborted

   f.Close
   oShell.Run "notepad.exe " & """" & sFile & """", 1, False
Else

   MsgBox "No entries found in Update History.", _
          vbInformation + vbSystemModal, "Update history"

End If
'--------------------8<----------------------

-- 
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx


Relevant Pages

  • Re: no signal error
    ... from biosupdate to the other updates. ... And also when i finally get into windows and just doing regular tasks as ... Select "review and install updates" and "install ... If you removed any softwares in step 7, restart computer. ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Latest Update Wreaked Havok - Cannot Restore
    ... track of what you install in order to be able to uninstall it. ... been diligent with your critical updates, ... Windows Update ... You should at least turn on the built in firewall. ...
    (microsoft.public.windowsxp.perform_maintain)
  • Re: Windows updates fail after install of SP2
    ... I'm sure I didn't delete any log files since my last update though; especially anything to do with Windows Update. ... Are the updates now showing in Add/Remove Programs in the Control ... I thought I would turn automatic updates on so that it would automatically download and install updates but that didn't seem to do anything either. ... The issue of updates not being offered after the application of SP2 is a new twist on an old theme ... ...
    (microsoft.public.windowsupdate)
  • Re: Windows 98 box is "owned"
    ... Microsoft officially is no longer issuing *new* updates for Windos 98, ... on Windows update, although you will find all the "critical" (as defined ... Perhaps it is time to say screw it and install ... You noted that your mother has ZA. ...
    (Security-Basics)
  • Re: Cannot View My Windows Update Installation History
    ... torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway ... "Windows Update does not use this to determine what updates should be offered ... data exists, also the description, the user that installed it and installation date. ... OS version: Microsoft Windows XP Professional ...
    (microsoft.public.windowsupdate)