Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Update > "View Installation History" for WU5 without using the WU Web site

Reply
Thread Tools Display Modes

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

 
 
Torgeir Bakken \(MVP\)
Guest
Posts: n/a

 
      08-12-2004
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/scr...r/default.mspx
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change permanently the "Text Size" under "View"? Phil [Switzerland] Windows Vista Mail 5 06-02-2008 09:53 PM
"View" Dropdown does not include "Thumbnails" self Windows Vista General Discussion 2 12-01-2007 06:04 AM
"Failed" status shown on installation history Mike Windows Update 1 01-20-2004 12:26 AM
"VIEW INSTALLATION HISTORY "QUESTION Dan Windows Update 1 01-13-2004 01:49 AM
History button shows "index" and "desktop" Kerry Windows Update 1 07-21-2003 10:19 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59