"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
- Next message: Greig [MSFT]: "Re: Updates failed"
- Previous message: Greig [MSFT]: "Re: Fonts"
- Messages sorted by: [ date ] [ thread ]
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
- Next message: Greig [MSFT]: "Re: Updates failed"
- Previous message: Greig [MSFT]: "Re: Fonts"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|