Guy said:
I would like to get rid of the "Cancelled" and "Failed" entries in the
Windows Update - Review your update history, because they are finally all
corrected installed.
How can i remove these enries from the history?
Hi,
You cannot, the only option is to clear out all the history
information, or nothing.
Using the VBScript below, you can get a report that only contains
the log entries that contains successfully installed updates.
Put the script in a text file with file extension .vbs (e.g.
WU_HistorySuccess.vbs) and run it by double-clicking on it.
'--------------------8<----------------------
' Script that reports only successfully installed updates (that are
' installed with Windows Update v5 or newer technology).
'
' Result will be written to %temp%\UpdateHistorySuccess.txt
' and then launched in Notepad
'
' Author: Torgeir Bakken
' Date 2005-07-02
'
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 "WU 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%") _
& "\UpdateHistorySuccess.txt"
Set f = oFSO.CreateTextFile(sFile, _
OverwriteIfExist, OpenAsASCII)
iTotal = 0
iSuccess = 0
iFailed = 0
iAborted = 0
iUnknown = 0
f.WriteLine "Report on successfully installed updates, run at " & Now
f.WriteLine "---------------------------------" _
& "---------------------------------"
Set colUpdate = oWU.QueryHistory(0, iTHCount)
For Each oUpdate In colUpdate
sErrorCode = ""
Select Case oUpdate.ResultCode
Case 2
sStatus = "Succeeded"
iSuccess = iSuccess + 1
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
f.WriteLine "---------------------------------" _
& "---------------------------------"
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
iTotal = iTotal + 1
Next
f.WriteLine
f.WriteLine "Total number of update log entries found: " & iTotal
f.WriteLine "Number of log entries with status success: " & iSuccess
f.WriteLine "Number of log entries with status failed: " & iFailed _
& " (not shown in list above!)"
f.WriteLine "Number of log entries with status aborted: " & iAborted _
& " (not shown in list above!)"
f.WriteLine "Number of log entries with status unknown: " & iUnknown _
& " (not shown in list above!)"
f.Close
oShell.Run "notepad.exe " & """" & sFile & """", 1, False
Else
MsgBox "No entries found in Update History.", _
vbInformation + vbSystemModal, "Update history"
End If
'--------------------8<----------------------