Windows 10 annoyingly automatically restarts without warning to install updates, potentially causing you to lose work that is left open. There is no easy option to stop this, but it is possible to continuously change the active hours window for your computer so that Windows 10 can’t find an inactive window to do this restart. Changing the active hours can be done by editing the registry, at HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings with the ActiveHoursStart and ActiveHoursEnd keys (DWORD values). I’ve tested this ‘fix’ for a few months and so far it seems to work as expected, although knowing Microsoft it may stop working at some stage, or for certain updates.

Provided here are three files to implement this scheme:

  1. ChangeActiveHours.bat which edits the registry to change the active hours to -1 to +9 of current time

  2. ChangeActiveHours.xml which is a Task Scheduler XML file to automatically execute the above batch file every hour in the background. This file will need to be edited with the location of ChangeActiveHours.bat under <Command>.

  3. CreateTaskChangeActiveHours.bat which automatically adds the above XML file to the Task Scheduler. Run as follows: CreateTaskChangeActiveHours.bat /ru "ComputerName\Username" /rp and it will prompt you for your password.