How to get a list of updates

How to get a list of updates

  • Comments 2

Today of my team members asked me, how to get a list of Office and Windows updates.

Surprisingly, I realized, that there is no easy way to do it (or at least I couldn’t find it ) – finally came up with following code snippets:

'For getting a list of office updates
'--- --- --- --- --- --- --- --- --- 
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32Reg_AddRemovePrograms where DisplayName Like '%update%office%' OR DisplayName Like '%update%visio%' OR DisplayName Like '%update%word%' OR DisplayName Like '%update%excel%' OR DisplayName Like '%update%powerpoint%' OR DisplayName Like '%update%project%' ",,48 )
For Each objItem in colItems
    Wscript.Echo "DisplayName: " & objItem.DisplayName
    Wscript.Echo "InstallDate: " & objItem.InstallDate
    Wscript.Echo "ProdID: " & objItem.ProdID
    Wscript.Echo "Publisher: " & objItem.Publisher
    Wscript.Echo "Version: " & objItem.Version
Next

'--- --- --- --- --- --- --- --- --- 
' For getting a list of  Windows Updates

' -----------------------------------
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_QuickFixEngineering",,48)
For Each objItem in colItems
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "CSName: " & objItem.CSName
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "FixComments: " & objItem.FixComments
    Wscript.Echo "HotFixID: " & objItem.HotFixID
    Wscript.Echo "InstallDate: " & objItem.InstallDate
    Wscript.Echo "InstalledBy: " & objItem.InstalledBy
    Wscript.Echo "InstalledOn: " & objItem.InstalledOn
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "ServicePackInEffect: " & objItem.ServicePackInEffect
    Wscript.Echo "Status: " & objItem.Status
Next

'-----------------------------------

 

 



Not responsible for errors in content, meaning, tact, or judgment. Live and let live. Toes go in first. I didn't do it. Enjoy.

Leave a Comment
  • Please add 4 and 2 and type the answer here:
  • Post
Page 1 of 1 (2 items)