6

I want a Windows 8.1 Professional installation which is always running and accessed by users via RDP to install updates automatically and also reboot automatically if the updates require it, but this should only happen saturday night (at any other time the system needs to be running and available for users).

I changed the following registry settings:

In HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU:

  • AUOptions = 4 (Automatically download and scheduled installation)
  • ScheduledInstallDay = 7 (saturday)
  • ScheduledInstallTime = 0 (0 o'clock)
  • NoAutoRebootWithLoggedOnUsers = 0 (also reboot with logged in users)
  • AlwaysAutoRebootAtScheduledTime = 1 (force restart)

Unfortunately, this does not always work. It worked once when I set the ScheduledInstallDay to thursday because I read in the documentation for AlwaysAutoRebootAtScheduledTime:

When this registry value is set to 1, you are still notified of the upcoming automatic restart on the sign-in screen. However, at the end of the three-day period, the 15-minute counter begins even if the computer is locked. The restart also occurs even if the computer is locked.

Source: How to force automatic restarts after important updates in Windows 8 and Windows Server 2012

So I thought if I want the system to restart on saturday, I have to set the scheduled day three days before that, because the restart is delayed 3 days. But the system restarted on thursday. Therefor I set the scheduled day to saturday again, but now the restart did not happen at all (I always have to wait for the next update which requires a restart to test the new settings).

How do I have to configure the system so that it always reboots on saturday night if an installed update requires it, even when a user is logged in at that time?

Update: As there is still no answer, I'm starting to believe that I'm on a completely wrong path here. I would also be happy for pointers how such a thing should be done, e.g. how do you keep a remotely accessed Windows machine always up to date when there is a fixed time window for updates?

  • If you downvote please explain what I can improve on this question. – Sven Koschnicke Jul 29 '15 at 6:20
  • As you can see the windows update settings don't always run to the same logic you might expect. Why not just reboot the machine every Saturday? – Drifter104 Aug 12 '15 at 8:35
  • Periodically rebooting would mean that users need to reconnect and reopen their applications, even when there was no need for a reboot (I think there was no update requiring a reboot for the last month or so). This is a solution, but not an optimal one. I would rather try to write a script which checks if the reboot is needed, but I thought there is a build in mechanism, especially as the settings suggest that there is one. – Sven Koschnicke Aug 12 '15 at 9:04
2
+50

This will do what you want with a powershell script.

download the powershell function/module from here https://gallery.technet.microsoft.com/scriptcenter/Get-PendingReboot-Query-bdb79542

Then edit the powershell profile for all users so that function gets loaded automatically. This link explains how to do that http://www.gsx.com/blog/bid/81096/Enhance-your-PowerShell-experience-by-automatically-loading-scripts

Then create a scheduled task to run the following powershell commands

$RebootStatus = "NotSet"

$RebootStatus = Get-PendingReboot | Select WindowsUpdate | Where-Object {$_.WindowsUpdate -like "True"}

if ($RebootStatus -ne $null) {shutdown -r -f -t 60}

Basically if the return value is false it sets $RebootStatus to empty, otherwise it populates it with a value. It checks that and reboots if $RebootStatus has any value other then $null.

Sorry if this goes over things you already know.

  • I suggested this as a script because as you have already found out, the update settings simply don't work as expected – Drifter104 Aug 12 '15 at 9:28
  • Looks good! I will try that. Why are you setting $RebootStatus to "NotSet" initially? – Sven Koschnicke Aug 12 '15 at 11:52
  • @SvenKoschnicke habbit (bad habbit?) of setting and declaring them. It could be set to anything I suppose. I can get by with scripting but I've no idea on some of the best ways of doing things – Drifter104 Aug 12 '15 at 12:20
  • All installed. Unfortunately, I can't know if this works until the next windows update which needs a restart. So I will not accept the answer for now, but you get the bounty because it would expire too early. – Sven Koschnicke Aug 12 '15 at 12:53
  • Thank you, let me know if it doesn't work and I'll make changes – Drifter104 Aug 12 '15 at 12:56

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.