Information Technology Grimoire

Version .0.0.1

IT Notes from various projects because I forget, and hopefully they help you too.

Disable Automatic Reboot Win11

Why Disable Auto Reboots?

If a car auto shutdown and kicked out it’s passengers at hours when it thought you were likely not driving, you’d be upset. Assuming that the computer you are working on has many tabs, logins, documents, database connections and other things that you need to plan to shutdown - why would you ever force a reboot on someone?

Anyway, Micro$loth has not made it easy to disable this, so I’m documenting the method for the next time I need to deal with it.

To be fair, reboots ARE needed, and that’s ok. But I will tell my computer when to reboot.

Old Windows 10/gpedit.msc Method

This method used to work, if you enabled gpedit.msc

FOR %F IN ("%SystemRoot%\servicing\Packages\Microsoft-Windows-GroupPolicy-ClientTools-Package~*.mum") DO (DISM /Online /NoRestart /Add-Package:"%F")
FOR %F IN ("%SystemRoot%\servicing\Packages\Microsoft-Windows-GroupPolicy-ClientExtensions-Package~*.mum") DO (DISM /Online /NoRestart /Add-Package:"%F")

But on Win 11, the gpo section is missing, so this no longer works, or maybe I did something in UI that doesn’t allow the section to show up.

  1. Click on the “Start” button and type gpedit.msc

  2. In the Local Group Policy Editor, go to Computer Configuration -> Administrative Templates -> Windows Components -> Windows Update

  3. Double-click on “No auto-restart with automatic installations of scheduled updates”.

  4. Select “Enabled”, and then click “OK”.

  5. Close the local group policy editor.

Then running gpupdate /force

Scripted Control of Forced Reboots

As I couldn’t get it to work with gpedit, There is a script instead.

Before the Disable Windows 11 Reboot Script

C:\Windows\System32\Tasks\Microsoft\Windows>dir /Q UpdateOrchestrator
 Volume in drive C has no label.
 Volume Serial Number is 7CA9-2B70

 Directory of C:\Windows\System32\Tasks\Microsoft\Windows\UpdateOrchestrator

05/30/2024  12:00 PM    <DIR>          NT AUTHORITY\SYSTEM    .
05/11/2024  06:12 AM    <DIR>          NT AUTHORITY\SYSTEM    ..
04/29/2024  04:45 PM             2,820 NT AUTHORITY\SYSTEM    Reboot_AC
04/29/2024  04:45 PM             2,776 NT AUTHORITY\SYSTEM    Reboot_Battery
04/29/2024  04:45 PM             3,320 BUILTIN\Administrators Report policies
04/29/2024  04:45 PM             2,222 NT AUTHORITY\SYSTEM    Schedule Maintenance Work
05/30/2024  12:14 PM             3,986 NT AUTHORITY\SYSTEM    Schedule Scan
04/29/2024  04:45 PM             5,640 BUILTIN\Administrators Schedule Scan Static Task
05/30/2024  12:15 AM             3,376 NT AUTHORITY\SYSTEM    Schedule Wake To Work
05/30/2024  12:12 PM             3,362 NT AUTHORITY\SYSTEM    Schedule Work
04/29/2024  04:45 PM             3,026 BUILTIN\Administrators Start Oobe Expedite Work
04/29/2024  04:45 PM             3,026 BUILTIN\Administrators StartOobeAppsScanAfterUpdate
04/29/2024  04:45 PM             3,004 BUILTIN\Administrators StartOobeAppsScan_LicenseAccepted
04/29/2024  04:45 PM             3,282 BUILTIN\Administrators USO_UxBroker
04/29/2024  04:45 PM             2,998 BUILTIN\Administrators UUS Failover Task
              13 File(s)         42,838 bytes
                      162,747,691,008 bytes free

Batch Script to Disable Auto Reboots in Win 11

The commands need to be run from an admin prompt. YOu can paste like they are, or save as a .bat file and then execute it.

@echo off
REM Change the working directory to C:\Windows\System32\Tasks\Microsoft\Windows
cd C:\Windows\System32\Tasks\Microsoft\Windows

REM Display the ownership of the UpdateOrchestrator directory and its contents
dir /Q UpdateOrchestrator

REM Take ownership of the UpdateOrchestrator directory and all its contents, assign it to the Administrators group
takeown /F UpdateOrchestrator /A /R /D y

REM Reset the permissions of the UpdateOrchestrator directory and all its contents to the default inherited permissions
icacls UpdateOrchestrator /reset /T /C

REM Grant full control permissions to the Administrators group for the UpdateOrchestrator directory and its contents
icacls UpdateOrchestrator /T /C /grant *S-1-5-32-544:F

REM Change the working directory to UpdateOrchestrator
cd UpdateOrchestrator

REM Rename existing directories to create backups
rename Reboot Reboot.backup
rename Reboot_Battery Reboot_Battery.backup
rename Reboot_AC Reboot_AC.backup
rename USO_UxBroker USO_UxBroker.backup

REM Create new empty directories with the same names as the ones backed up
mkdir Reboot
mkdir Reboot_Battery
mkdir Reboot_AC
mkdir USO_UxBroker

REM Create empty files named empty_file in each of the newly created directories
copy NUL Reboot\empty_file
copy NUL Reboot_Battery\empty_file
copy NUL Reboot_AC\empty_file
copy NUL USO_UxBroker\empty_file

REM Change the working directory back to the parent directory
cd ..

REM Display the ownership of the UpdateOrchestrator directory and its contents again
dir /Q UpdateOrchestrator

By making a backup, of the files, I can restore, and by making a directory with the same name as the file, windows cannot “fix it”.

Now if it tries to reboot, it can’t.

After the Disable Windows 11 Reboot Script

C:\Windows\System32\Tasks\Microsoft\Windows>dir /Q UpdateOrchestrator
 Volume in drive C has no label.
 Volume Serial Number is 7CA9-2B70

 Directory of C:\Windows\System32\Tasks\Microsoft\Windows\UpdateOrchestrator

05/30/2024  12:00 PM    <DIR>          BUILTIN\Administrators .
05/11/2024  06:12 AM    <DIR>          NT AUTHORITY\SYSTEM    ..
05/30/2024  12:00 PM    <DIR>          BUILTIN\Administrators Reboot
05/30/2024  12:00 PM    <DIR>          BUILTIN\Administrators Reboot_AC
04/29/2024  04:45 PM             2,820 BUILTIN\Administrators Reboot_AC.backup
05/30/2024  12:00 PM    <DIR>          BUILTIN\Administrators Reboot_Battery
04/29/2024  04:45 PM             2,776 BUILTIN\Administrators Reboot_Battery.backup
04/29/2024  04:45 PM             3,320 BUILTIN\Administrators Report policies
04/29/2024  04:45 PM             2,222 BUILTIN\Administrators Schedule Maintenance Work
05/30/2024  12:14 PM             3,986 BUILTIN\Administrators Schedule Scan
04/29/2024  04:45 PM             5,640 BUILTIN\Administrators Schedule Scan Static Task
05/30/2024  12:15 AM             3,376 BUILTIN\Administrators Schedule Wake To Work
05/30/2024  12:12 PM             3,362 BUILTIN\Administrators Schedule Work
04/29/2024  04:45 PM             3,026 BUILTIN\Administrators Start Oobe Expedite Work
04/29/2024  04:45 PM             3,026 BUILTIN\Administrators StartOobeAppsScanAfterUpdate
04/29/2024  04:45 PM             3,004 BUILTIN\Administrators StartOobeAppsScan_LicenseAccepted
05/30/2024  12:00 PM    <DIR>          BUILTIN\Administrators USO_UxBroker
04/29/2024  04:45 PM             3,282 BUILTIN\Administrators USO_UxBroker.backup
04/29/2024  04:45 PM             2,998 BUILTIN\Administrators UUS Failover Task