Scripted Windows Updates Installation


This article contains only several links to the documents I found when I was trying to automate Windows Updates installation. However, this set of links could be very useful.

Windows Update Agent API (http://msdn.microsoft.com/en-us/library/aa387287%28v=VS.85%29.aspx) is used for the scripting.

Windows Update Agent Object Model can be found here: (http://msdn.microsoft.com/en-us/library/aa387291%28v=VS.85%29.aspx)

Here is a short example:

strComputerName = “RemoteComputer”
Set objSession = CreateObject(“Microsoft.Update.Session”‘, strComputerName)

Set objSearcher = objSession.CreateUpdateSearcher
Set colHistory = objSearcher.QueryHistory(1, 1)
For Each objEntry in colHistory
Wscript.Echo “Title: ” & objEntry.Title
Wscript.Echo “Update application date: ” & objEntry.Date
Next

Set objInstaller = objSession.CreateUpdateInstaller
Set colUpdates = objInstaller.Updates
For Each objEntry in colUpdates
Wscript.Echo “Title: ” & objEntry.Title
Wscript.Echo “Update application date: ” & objEntry.Date
Next

Note: The second parameter in CreateObject(“Microsoft.Update.Session”‘, strComputerName) allows to create the UpdateSession object on a remote computer.

Unfortunatelly, not all of the interfaces can work on the remote computer. From the example above, UpdateSearcher will work while UpdateInstaller will not. The full list of interfaces divided by ability to work on the remote computer is here: (http://msdn.microsoft.com/en-us/library/aa387288%28v=VS.85%29.aspx).

If the script will work on a local computer only, it is better to use CreateObject with only one parameter

An example on how to report updates needed by clients is here: (http://msdn.microsoft.com/en-us/library/ms744621%28v=VS.85%29.aspx).

The interfaces useful to retrieve the update installation status are listed here: (http://msdn.microsoft.com/en-us/library/ms744640%28v=VS.85%29.aspx)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: