I need to schedule an unattended weekly out of hours download & install of windows updates and then reboot of a Windows Server 2016 box. How can I do this? Can it be done from the command line?

Similar question regarding Windows 2003 Schedule Windows Updates exclusively on a specific work day (and time)?

  • Most in an enterprise environment use SCCM or similar management software. – Colyn1337 Jun 21 '17 at 19:58
  • The trick is in controlling the reboot that most updates require. You could certainly use a third party utility for this, which is what one of my clients does. – joeqwerty Jun 21 '17 at 20:00

You should be able to do it via Group Policy, under "Computer Configuration"->"Administrative Templates"->"Windows Components"->"Windows Update", changing the policy setting there.

Alternatively, you can do it by running wuauclt /detectnow to check if there are any Microsoft Updates outstanding for installation. Putting that into a scheduled task should give you what you want.

Edit: It seems that wuauclt no longer works in Windows 10 (and presumably Server 2016). Instead, you can either create a script based on %windir%\System32\en-US\WUA_SearchDownloadInstall.vbs, which is used by sconfig, or you can download the script from https://gallery.technet.microsoft.com/scriptcenter/VB-Script-to-Check-and-620579cd and check if it works for you. (Note that the latter will skip any updates that require user input as that won't be possible during an unattended update.)

|improve this answer|||||
  • This has no effect in Windows Server 2016, could be related to similar problem in Windows 10? answers.microsoft.com/en-us/windows/forum/windows_10-update/… – userSteve Jun 22 '17 at 11:13
  • Thanks, I have set the Local Policy to update and reboot once a week. Hopefully it will work. – userSteve Jun 22 '17 at 11:33
  • 1
    Thanks for the note about wuauclt not working in Windows Server 2016...I've made a change to reference something that should work. – Pak Jun 22 '17 at 12:07
  • BTW, it does seem strange to get a downvote for an answer (albeit one with an incorrect component), but I'll live with it. – Pak Jun 22 '17 at 12:14
  • Pak - the downvote was accidental! Sorry. Couldnt seem to reverse it ? – userSteve Jun 23 '17 at 8:25

There is indeed a command line tool that is exactly built for your use case - have a look at WuInstall (http://www.wuinstall.com) - it is a commercial product intended for companies with 50 machines and more but you can always download a free trial version to test in your environment

You can put wuinstall.exe in a batch script on the same machine or you can call it remotely via psexec

In the simplest case (you will also probably need a few more options for pruction environments) just write your batch script calling

wuInstall /install /reboot_if_needed

and kick it of with a task scheuduler of your choice at the time you want to update.

With the /reboot_if_needed option it is possible to reboot the machine unattended after the update, and the /rebootcylce option even reboots multiple times until all updates are installed.

WuInstall basically puts the whole Windows Update API and its most common use cases in one central command line tool - There are quite a few more options to script and select windows updates, check out the technical documentation under: https://wuinstall.atlassian.net/wiki/display/WD/WuInstall+HowTo

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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