msoff20xx

How to list all currently installed Win7 patches/updates?

24 posts in this topic

How can I list which of the available Win7 patches/updates from Microsoft are currently really applied and installed on the local Win7 system?

The list of patches/updates should cover updates for Offcie 2003/2007 as well.

How can I list the information?

Peter

0

Share this post


Link to post
Share on other sites

This is easy to do in VBScript or Powershell, but since VBScript is a little easier to understand and will work (relatively speaking) downlevel on stock XP/2003 and 2000 SP3 systems as well, I'll do it in VBScript:

'// Run with cscript:
RunMeWithCScript()


'// Connect to the Windows Update COM object:
Set objSession = CreateObject("Microsoft.Update.Session")
Set objSearcher = objSession.CreateUpdateSearcher
intHistoryCount = objSearcher.GetTotalHistoryCount

'// Get WU history data:
Set colHistory = objSearcher.QueryHistory(1, intHistoryCount)

'// Loop through and print to screen:
For Each objEntry in colHistory
WScript.Echo "=============================="
WScript.Echo objEntry.Title
WScript.Echo ""
WScript.Echo "Support URL: " & vbCrLf & objEntry.SupportURL
WScript.Echo ""
WScript.Echo "Description: " & vbCrLf & objEntry.Description
WScript.Echo ""
WScript.Echo "Installed On: " & vbCrLf & objEntry.Date
WScript.Echo ""
Select Case objEntry.ResultCode
Case 1 ResultCode = "Pending Reboot"
Case 2 ResultCode = "Successfully Installed"
Case 4 ResultCode = "Installation Failed"
Case 5 ResultCode = "Installation Canceled"
Case Else
ResultCode = "Unknown Installation Status"
End Select
WScript.Echo "Result code: " & vbCrLf & ResultCode
WScript.Echo ""
WScript.Echo "Client application ID: " & vbCrLf & objEntry.ClientApplicationID
i = 1
For Each strStep in objEntry.UninstallationSteps
WScript.Echo i & " -- " & strStep
i = i + 1
Next
If objEntry.UninstallationNotes = "" Then
' No uninstallation notes, print nothing
Else
WScript.Echo ""
WScript.Echo "Uninstallation notes: " & vbCrLf & objEntry.UninstallationNotes
End If
WScript.Echo "=============================="
WScript.Echo ""
WScript.Echo ""
Next


Sub RunMeWithCScript()
Dim ScriptEngine, engineFolder, Args, arg, scriptName, argString, scriptCommand

ScriptEngine = UCase(Mid(WScript.FullName, InstrRev(WScript.FullName, "\") + 1))
engineFolder = Left(WScript.FullName, InstrRev(WScript.FullName, "\"))
argString = ""

If ScriptEngine = "WSCRIPT.EXE" Then
Dim Shell
Set Shell = CreateObject("WScript.Shell")
Set Args = WScript.Arguments

For Each arg in Args 'loop though argument array as a collection to rebuild argument string
If InStr(arg, " ") > 0 Then arg = """" & arg & """" 'If the argument contains a space wrap it in double quotes
argString = argString & " " & Arg
Next

'Create a persistent command prompt for the cscript output window and call the script with its original arguments
scriptCommand = "cmd.exe /k " & engineFolder & "cscript.exe """ & WScript.ScriptFullName & """" & argString

Shell.Run scriptCommand, , False
WScript.Quit
Else
Exit Sub 'Already Running with Cscript Exit this Subroutine
End If
End Sub

0

Share this post


Link to post
Share on other sites

Hmm, when I try to run your script (see above) then I get an error popup:

line 8

Char 1

The service cannot be started, either because it is disabled or because it has noenabled device associated with it

Code 80070422

I don't know which service or deviuce is meant.

How can I run this script otherwise or enable (which?) service?

Peter

0

Share this post


Link to post
Share on other sites

The script run without errors for me.

But I have to click ok for each line that is echoed.

how can I get it to print to a file?

0

Share this post


Link to post
Share on other sites

Hmm, when I try to run your script (see above) then I get an error popup:

line 8

Char 1

The service cannot be started, either because it is disabled or because it has noenabled device associated with it

Code 80070422

I don't know which service or deviuce is meant.

How can I run this script otherwise or enable (which?) service?

Peter

It's connecting to the Windows Update Service COM object. If you've disabled Windows Update or any of it's dependencies, this is the error you'll get. You can't enumerate updates that are tracked by the service if you've disabled it.

The script run without errors for me.

But I have to click ok for each line that is echoed.

how can I get it to print to a file?

Edit: Script updated to spawn itself via cscript in a cmd prompt, even if double-clicked.
0

Share this post


Link to post
Share on other sites

You could also:

go into control panel

Select small icons view

Select "Windows update" at the bottom

Then bottom left - see also - Installed updates

This will list all installed updates on the system.

0

Share this post


Link to post
Share on other sites

Sometimes, it helps to be able to have the data for analysis or for automation, though. The script (and other means) can be useful for that.

Edited by Glenn9999
0

Share this post


Link to post
Share on other sites

Not to mention if the user's disabled the WU service, The Windows Update panel won't show you an update history either until you enable it - it uses the same COM object for the WU window. Clicking "view history" when the service is disabled will just give you a blank screen with an OK button. ;)

0

Share this post


Link to post
Share on other sites

Decided to write one to also show updates that are applicable to a Win7 system but are not installed as well, because I ended up needing something like this last night:

'// Run with cscript:
RunMeWithCScript()


'// Connect to the Windows Update COM object:
Set objSession = CreateObject("Microsoft.Update.Session")
Set objSearcher = objSession.CreateUpdateSearcher
Set colSearchResult = objSearcher.Search("IsInstalled=0")

'// Loop through and print to screen updates that are not drivers or language packs:
For I = 0 To colSearchResult.Updates.Count-1
isLanguagePack = False
Set update = colSearchResult.Updates.Item(I)
For Each Category In update.Categories
categoryID = Category.CategoryID
Next
If categoryID = "6d76a2a5-81fe-4829-b268-6eb307e40ef3" Then
'Language Pack, print nothing and move to next item
ElseIf update.Type = 2 Then
'Driver, print nothing and move to next item
Else
WScript.Echo "=============================="
WScript.Echo update.Title
WScript.Echo ""
WScript.Echo "Support URL: " & vbCrLf & update.SupportURL
WScript.Echo ""
For Each KB In update.KBArticleIDs
WScript.Echo "KB Article ID: " & vbCrLf & KB
Next
WScript.Echo ""
WScript.Echo "Update Description: " & vbCrLf & update.Description
x = 1
For Each strStep in update.UninstallationSteps
WScript.Echo x & " -- " & strStep
x = x + 1
Next
If update.UninstallationNotes = "" Then
' No uninstallation notes, print nothing
Else
WScript.Echo ""
WScript.Echo "Uninstallation notes: " & vbCrLf & update.UninstallationNotes
End If
WScript.Echo "=============================="
WScript.Echo ""
WScript.Echo ""
End If
Next


Sub RunMeWithCScript()
Dim ScriptEngine, engineFolder, Args, arg, scriptName, argString, scriptCommand

ScriptEngine = UCase(Mid(WScript.FullName, InstrRev(WScript.FullName, "\") + 1))
engineFolder = Left(WScript.FullName, InstrRev(WScript.FullName, "\"))
argString = ""

If ScriptEngine = "WSCRIPT.EXE" Then
Dim Shell
Set Shell = CreateObject("WScript.Shell")
Set Args = WScript.Arguments

For Each arg in Args 'loop though argument array as a collection to rebuild argument string
If InStr(arg, " ") > 0 Then arg = """" & arg & """" 'If the argument contains a space wrap it in double quotes
argString = argString & " " & Arg
Next

'Create a persistent command prompt for the cscript output window and call the script with its original arguments
scriptCommand = "cmd.exe /k " & engineFolder & "cscript.exe """ & WScript.ScriptFullName & """" & argString

Shell.Run scriptCommand, , False
WScript.Quit
Else
Exit Sub 'Already Running with Cscript Exit this Subroutine
End If
End Sub

0

Share this post


Link to post
Share on other sites

Hi

Thanks for the ultimate tool to check un/installed updates.

Can we export the outcome of the script to a excel worksheet?

RK

0

Share this post


Link to post
Share on other sites

@cluberti:

Thank you for these easy & very useful VBScripts. The "not installed" script worked perfectly & showed the 9 updates I have chosen to hide.

The "installed" script only showed 11 results (attached), however in WU cpl I have the following:

4 "Hotfix"

42 "Security"

19 "Update"

IE 9

--------------

66 total

Win 7 Home Prem SP1 x64 on a Gateway NV59C Notebook, recently (about a week ago) clean installed to rid myself of the OEM bloat...if that makes any difference.

Edited by PinkFreud
0

Share this post


Link to post
Share on other sites

This is querying the same APIs that the inbox Windows Update uses, so assuming it's not showing everything that you've installed, the only thing that would make sense would be that you installed the patches manually (outside of WU). Otherwise, I'm not sure why this would be so. If you go to Windows Update and click the "view update history" link, does the output from my script match the output there? It should....

0

Share this post


Link to post
Share on other sites

Run this command from CMD:

WMIC WFE LIST FULL

You can export to HTML / CSV / TXT

Not need install anything.

0

Share this post


Link to post
Share on other sites

This is querying the same APIs that the inbox Windows Update uses...the only thing that would make sense would be that you installed the patches manually (outside of WU)...If you go to Windows Update and click the "view update history" link, does the output from my script match the output there? It should....

Thank you for your follow-up, it is much appreciated. In reply to the above:

1) All updates installed via WU except the 4 hotfixes mentioned-- all 4 show under Control Panel\All Control Panel Items\Windows Update--Installed Updates tab, 2 show under \View update history

2) It does not. (PNG's attached) Including Hotfixes, IE9, MSSE , MSRT there are 72 items listed under "History"--vs 66 under "Installed"

Just for the halibut, I re-ran the VBScript--same result. :(

:unsure::blink:

0

Share this post


Link to post
Share on other sites

I wrote this VBS script that makes a HTA that list the missing and installed updates.

I Gunsmokingman give all users full permission to do what ever they want with this script.

Save As KB_Report.vbs

'-> This code is property of Gunsmokingman and Or Jake1Eye and you must have his permission to use.'-> This is only posted as example code and meant only to used as such.'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''/-> Varibles And Objects For The ScriptDim Act, CName, CN, Fso, UpdateSession, UpdateSearcherSet Act = CreateObject("Wscript.Shell")Set Fso = CreateObject("Scripting.FileSystemObject")Set updateSession = CreateObject("Microsoft.Update.Session")Set updateSearcher = updateSession.CreateupdateSearcher()CName = Act.ExpandEnvironmentStrings("%ComputerName%")'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''/-> Ask If You Want To Use ScriptDim A1A1 = Act.Popup( _" Would You Like To Run The Report Updates Script?" & vbCrLf &_"The Script Will Take Approx 5 Minutes To Be Done." & vbCrLf &_"If Nothing Is Selected This Will Self Close In 7" & vbCrLf &_"Seconds And Do Nothing", 7, "Search Updates",4132)If A1 = 7 Or A1 = -1 ThenWScript.Quit(1)End If'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''/-> Varibles For The ScriptDim Arg1, Arg2, Arg3, C1, DT, Hta1, Hta2, Hta3, Hta4Dim Rpt, Str1, Str2, Str3, SearchResult, TS, Update, Var1, Var2, Var3'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''/-> Replace Any Spaces In The Computer NameIf InStr(CName," ") ThenCN = Replace(CName," ", "_")ElseCN = CNameEnd If'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''/-> Build The HtaDT = Act.SpecialFolders("Desktop")Rpt = (DT & "\" & CN & "_KbReport.hta")Rpt = Act.ExpandEnvironmentStrings("%UserProfile%\desktop\" & CN & "_KbReport.hta")Var1 = Chr(160) & Chr(171) & Chr(160)Var2 = Chr(160) & Chr(187) & Chr(160)Var3 = Var1 & "---------------------------------------" & Var2Set SearchResult = UpdateSearcher.Search("IsInstalled=0 and Type='Software'")Set TS = Fso.CreateTextFile(Rpt)TS.WriteLine "<TITLE>" & CName & "</TITLE>" & vbCrLf &_"<STYLE Type=""text/css"">" & vbCrLf &_" Body{Font-Size:9.25pt;Font-Weight:Bold;" & vbCrLf &_" Font-Family:segoeui,helvetica,verdana,arial,Poor Richard;" & vbCrLf &_" Color:#000063;BackGround-Color:Transparent;" & vbCrLf &_" Filter:progid:DXImageTransform.Microsoft.Gradient" & vbCrLf &_" (StartColorStr='#fdf7f1',endColorStr='#d1cbc5');" & vbCrLf &_" Margin-Top:5;Margin-Bottom:5;Margin-Left:4;Margin-Right:4;" & vbCrLf &_" Padding-Top:5;Padding-Bottom:5;Padding-Left:4;Padding-Right:4;" & vbCrLf &_" Text-Align:Left;Vertical-Align:Top;" & vbCrLf &_" Border-Top:2px Solid #cbc7c3;Border-Bottom:3px Solid #a6a29e;" & vbCrLf &_" Border-Left:2px Solid #bcb8b4;Border-Right:3px Solid #b2aeaa;}" & vbCrLf &_" Table.Table1{Font-Size:8.25pt;Color:Blue;Font-Weight:Bold;Width:395px;}" & vbCrLf &_" Div.D1{Font-Size:8.25pt;Color:#1e1e1e;Padding-Left:25;Width:97%;}" & vbCrLf &_" Font.F1{Color:#004400;Padding-Left:18;}" & vbCrLf &_" Font.F2{Font-Weight:Bold;Color:#000063;Padding-Left:23;}" & vbCrLf &_"</STYLE>" & vbCrLf &_"<script LANGUAGE='JScript'>window.resizeTo (675,395), window.moveTo (210,175);</SCRIPT>"TS.WriteLine "<BODY><CENTER><TABLE>" & Var1 & Now() & Var2 &_"</TABLE><TABLE>List Of Missing Updates</TABLE><HR Width=95%></CENTER>"For I = 0 To searchResult.Updates.Count-1C1 = C1 + 1If Len(C1) = 3 Then C1 = C1If Len(C1) = 2 Then C1 = "0" & C1If Len(C1) = 1 Then C1 = "00" & C1Set Update = SearchResult.Updates.Item(I)RptUpdate()Arg3 = Arg3 & vbCrLf & Update.TitleNext'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''/-> If There Are No Updates To Install On The MachineIf SearchResult.Updates.Count = 0 ThenTS.WriteLine "<FONT Class='F1;'>" & Var1 & C1 & Var2 & "</FONT>" & vbCrLf &_"<FONT Class='F2'>There Are No Applicable Updates, To Install""</FONT>" & vbCrLf &_"<CENTER><HR Width=95%></CENTER>"End IfDim SResultsC1 = 0TS.WriteLine "<CENTER><TABLE>List Of Installed Updates</TABLE><HR Width=95%></CENTER>"Set SResults = UpdateSearcher.Search("IsInstalled=1 and Type='Software'")For I = 0 To SResults.Updates.Count-1C1 = C1 + 1If Len(C1) = 3 Then C1 = C1If Len(C1) = 2 Then C1 = "0" & C1If Len(C1) = 1 Then C1 = "00" & C1Set Update = SResults.Updates.Item(I)RptUpdate()Next'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''/-> Report The Update InformationFunction RptUpdate()TS.WriteLine "<FONT Class='F1;'>" & Var1 & C1 & Var2 & "</FONT>" & vbCrLf &_"<FONT Class='F2'>" & Update.Title & "</FONT>" & vbCrLf &_"<DIV Class='D1'>  " & Update.Description & "</DIV>" & vbCrLf &_"<CENTER><HR Width=95%></CENTER>"End FunctionTS.Close'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''/-> Run The HtaSet Arg1 = Fso.GetFile(Rpt)Act.Run("mshta.exe " & Chr(34) & Arg1.Path & Chr(34)),1,True'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''/-> Keep Or Delete The Hta ReportIf MsgBox("Did You Want To Keep The HTA Update Report?" & vbCrLf & _"Yes To Keep The Hta, No To Delete The Hta.",4132,"Keep Or Delete") = 7 ThenFso.DeleteFile Arg1End If
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.