Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
:: ChangeActiveHours
:: Setting Active Hours Start (AHS) and End (AHE) times to 1 hour before the current time through 9 hours after the current time, i.e. a total of 10 hours window
:: Source: https://www.tenforums.com/windows-updates-activation/59724-how-prevent-automatic-restart-windows-10-anniversary-update-6.html#post858630
:: Tet Woo Lee Bugfix, GTR 23 instead of 24 for correct behaviour at 15:00 + 9hrs = 24:00 -> 0:00
@ECHO off
set /a AHS=%time:~0,2%-1
IF %AHS% LSS 0 set /a AHS=%AHS%+24
set /a AHE=%time:~0,2%+9
IF %AHE% GTR 23 set /a AHE=%AHE%-24
echo Setting Active hours to between %AHS% and %AHE%
reg.exe ADD HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings /v ActiveHoursStart /t REG_DWORD /f /d %AHS%
reg.exe ADD HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings /v ActiveHoursEnd /t REG_DWORD /f /d %AHE%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment