Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to the Power Users community on Codidact!

Power Users is a Q&A site for questions about the usage of computer software and hardware. We are still a small site and would like to grow, so please consider joining our community. We are looking forward to your questions and answers; they are the building blocks of a repository of knowledge we are building together.

Post History

71%
+3 −0
Q&A How to stop all automatic Windows Update restarts on a Windows 10 Pro machine?

Windows 10 allows you to set "office hours" during which it won't automatically reboot. Unfortunately, it doesn't allow you to set the entire day as office hours. So the trick is to change your off...

posted 3y ago by Peter Taylor‭

Answer
#1: Initial revision by user avatar Peter Taylor‭ · 2021-06-14T07:08:18Z (almost 3 years ago)
Windows 10 allows you to set "office hours" during which it won't automatically reboot. Unfortunately, it doesn't allow you to set the entire day as office hours. So the trick is to change your office hours frequently in such a way that it's always office hours.

https://github.com/Maimer/update-active-hours contains a simple implementation of this trick; I have an uncommitted fork which offsets 1 hour back in the past - I can't remember, but I may have found that this was necessary.

`update_active_hours.ps1`:

	$registryPath = "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings"

	if (Test-Path -Path "${registryPath}") {
	  $currentHour = (Get-Date).hour
	  $activeHoursStart = $currentHour - 1
	  if ($activeHoursStart -lt 0) {
		$activeHoursStart = $activeHoursStart + 24
	  }
	  $activeHoursEnd = $activeHoursStart + 12
	  if ($activeHoursEnd -gt 23) {
		$activeHoursEnd = $activeHoursEnd - 24
	  }
	  Set-ItemProperty -Path "${registryPath}" -Name "ActiveHoursStart" -Value "${activeHoursStart}"
	  Set-ItemProperty -Path "${registryPath}" -Name "ActiveHoursEnd" -Value "${activeHoursEnd}"
	}

This is run by a scheduled task which executes every 6 hours with action

    Powershell.exe -ExecutionPolicy Unrestricted -File path\to\update_active_hours.ps1