Forum Discussion
How to prevent all Windows 11 auto-reboots and auto-shutdowns?
You can create a batch file that changes your active hours and set up a scheduled task to repeat it every hour -- that way, there is never a time when you are not in active hours, which should block the update restarts.
for /f %%i in ('powershell "((get-date).Hour+18) %% 24"') do set startHour=%%i
for /f %%i in ('powershell "((get-date).Hour+12) %% 24"') do set endHour=%%i
reg add HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings /v ActiveHoursStart /t REG_DWORD /d %startHour% /f
reg add HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings /v ActiveHoursEnd /t REG_DWORD /d %endHour% /f
To make the batch file, open Notepad, copy-and-paste the above commands in, then save the file as any name with a .bat extension, for example noreboots.bat. You can save it anywhere, as long as you can find it.
To open the Task Scheduler, press the Windows Key + R at the same time, and write taskschd.msc in the prompt. In the next window, go into Action and click Create Task.
In the next window, in the General tab, give it a name, for instance 'No Reboots'. Then go to the Trigger tab, click New, select Daily, check the box next to Repeat task every: and set to 1 hour (or whatever interval you find appropriate). Click OK, then go to the Actions tab, click New, and click Browse, then navigate to the location you just saved your .bat file to. Select it.
If you are using a laptop, you will then want to go to the Conditions tab, and uncheck the two checked boxes under Power. Otherwise, the task will not start unless you boot the computer up while it's plugged in, and it will disable it if you unplug it.
Credit to The Curate for the idea and the code, from https://answers.microsoft.com/en-us/windows/forum/all/how-to-disable-windows-11-automatic-reboots/d7766f02-59a1-48f4-af6e-761345704ead.