Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to automatically install Windows server updates (backed by WSUS), but can't seem to get wuauclt /updatenow to actually initiate an install (or any of the other undocumented switches).

It works on a test workstation, but I believe that's because installation is set to Automatic Every Day while the server is set to Detect Only. I'm planning on using another, more robust 3rd party scheduler to install updates on certain days of the week, but also weeks of the month. i.e. Server A gets install on the first Sunday of the month, Server B, the second Sunday of the month, etc.

Basically I'm looking for a scriptable equivalent of clicking the "Install Updates" button on the Windows Update GUI dialog on the server.

share|improve this question
Does it have to be a script, will changing the Local Computer Policy to update when you want work? MMC -> Group Policy Object Editor -> Local Computer -> Computer Config -> Admin Templates -> Windows Components -> Windows Update – Sane Nov 15 '12 at 23:26
I wonder if I could script a registry modification prior to calling /updatenow. We'll see if anyone else chimes in but feel free to add your suggestion as an answer. – gravyface Nov 16 '12 at 0:31

Looks like you can do this with a COM API (so you can use any scripting language that can use COM-- VBScript, PowerShell, etc).

The snippet of VBScript below will search for pending updates, download them, and install them silently.

Option Explicit

Dim objUpdateSess
Dim objUpdateSearcher
Dim objDownloader
Dim objInstaller
Dim objSearchResult

Set objUpdateSess = CreateObject("Microsoft.Update.Session")

Set objUpdateSearcher = objUpdateSess.CreateUpdateSearcher()

Set objDownloader = objUpdateSess.CreateUpdateDownloader()

Set objInstaller = objUpdateSess.CreateUpdateInstaller()

' Search for pending updates
Set objSearchResult = objUpdateSearcher.Search("IsAssigned=1 and IsHidden=0 and IsInstalled=0 and Type='Software'")

' Download the pending updates
objDownloader.Updates = objSearchResult.Updates

' Install the pending updates
objInstaller.AllowSourcePrompts = False
objInstaller.ForceQuiet = True
objInstaller.Updates = objDownloader.Updates

This script has absolutely zero error checking, so don't actually use it! There are a slew of little scripts that people have written to automate this process all over the 'net (some that send emails, automatically reboot after completion, etc). Do some searching and see what you come up with or roll your own.

share|improve this answer
Nice, this looks like the right way to go. – gravyface Nov 16 '12 at 2:44

Microsoft has a great sample vbscript for installing updates via Windows Update at

There are a couple of tweaks I would make for your usage, such as auto accepting all EULAs and not stopping to ask any questions.

share|improve this answer
Doesn't work with WSUS (uses WUA). – gravyface Nov 16 '12 at 2:42
Um, this is exactly the same thing that Evan Anderson suggested. – longneck Nov 16 '12 at 3:58
Yep. Exactly the same thing. – Evan Anderson Nov 16 '12 at 4:36
oh, the first few bullets said it doesn't support SUS 1.0 (so I assumed that meant WSUS as well). – gravyface Nov 16 '12 at 14:32

Editing the Local Group Policy is the closest thing I can think of to doing what you may need.

  1. Hit the Windows key + R
  2. Type gpedit.msc
  3. Browse to: Computer Configuration -> Windows Components -> Windows Update
  4. Under there you can edit all the settings but the one you may be interested in the most is "Configure Automatic Updates", this policy will let you select a day and time to run Windows updates.

If the system is part of a domain you can do this with a group policy as well.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.