How to disable Windows 11 automatic reboots?

Anonymous
2024-02-18T11:19:20+00:00

Hi,

I have browsed this forum but found so far no real solution:

It has happened to my now several times that I was running tasks over extended periods of time only to come back to my PC the next morning to find Windows 11 had done an automatic reboot! So not only the tasks weren't finished, worse, lots of preparatory work was lost!

I don't want Windows to ever automatically reboot after an update. Never. Ever. Period. I want to be informed about updates, that's fine, and I keep Windows 11 up to date, but under no circumstances ever is it acceptable that Windows just shovels an update on my PC and disrupts overnight tasks and REBOOTS(!) my PC all by itself.

So it would be very helpful if somebody could tell me how to disable these automatic update reboots once and for all. I don't want to "pause" Updates (I absolutely want updates, I just want to control myself when the updates are done) and resetting "work hours" is of no use unless I can set it to 24 hours.

Best regards

Nick

Windows for home | Windows 11 | Windows update

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

84 answers

Sort by: Newest
  1. Anonymous
    2024-07-10T11:20:17+00:00

    Running this as admin in powershell will create a ps1 script that cancels pending restarts (with logging), and schedule it as a task.

    Microsoft, don't be Apple. This also is not an effective way to get me to PAY for pro, if that's your game.

    Create the script to cancel pending restarts with logging

    $scriptContent = @"

    `$logPath = "C:\Scripts\CancelRestartLog.txt"

    function Log-Message {

    param([string]`$message) 
    
    `$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" 
    
    "`$timestamp - `$message" | Out-File -FilePath `$logPath -Append 
    

    }

    Log-Message "Script execution started"

    $restartCancelled = $false

    if (Get-ChildItem "HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending" -EA Ignore) {

    shutdown /a 
    
    `$restartCancelled = `$true 
    

    }

    if (Get-ChildItem "HKLM:\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" -EA Ignore) {

    shutdown /a 
    
    `$restartCancelled = `$true 
    

    }

    if (Get-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending" -EA Ignore) {

    shutdown /a 
    
    `$restartCancelled = `$true 
    

    }

    if (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" -EA Ignore) {

    shutdown /a 
    
    `$restartCancelled = `$true 
    

    }

    if (Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager" -Name PendingFileRenameOperations -EA Ignore) {

    shutdown /a 
    
    `$restartCancelled = `$true 
    

    }

    if (`$restartCancelled) {

    Log-Message "Restart cancelled successfully" 
    

    } else {

    Log-Message "No pending restart detected" 
    

    }

    Log-Message "Script execution completed"

    "@

    Save the script to a file

    $scriptPath = "C:\Scripts\CancelRestart.ps1"

    New-Item -ItemType Directory -Force -Path (Split-Path $scriptPath)

    Set-Content -Path $scriptPath -Value $scriptContent

    Create a scheduled task

    $taskAction = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "-ExecutionPolicy Bypass -File "$scriptPath""

    $taskTrigger = New-ScheduledTaskTrigger -Once -At (Get-Date) -RepetitionInterval (New-TimeSpan -Minutes 15)

    $taskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit (New-TimeSpan -Minutes 5)

    $taskPrincipal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -LogonType ServiceAccount -RunLevel Highest

    Register-ScheduledTask -TaskName "CancelWindowsRestart" -Action $taskAction -Trigger $taskTrigger -Settings $taskSettings -Principal $taskPrincipal -Force

    Write-Host "Script created and scheduled task set up successfully. Logs will be written to C:\Scripts\CancelRestartLog.txt"

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2024-07-10T09:21:57+00:00

    I think you set the repeat time wrong. go to tasks and edit it in order to run every 1 hour.

    Another issue happen to me. sometimes the batch windows does not close, waiting to a response in a prompt. A Yes or No prompt and I every time press Y. No all the time the window stops asking for the answer, but, still less annoying than the restart without asking issue.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  3. Anonymous
    2024-07-09T19:57:28+00:00

    Hi Mauro,

    This seems to stop the update, but, the command prompt window opens repeatedly (like every 10 minutes) to run this code and the window opens over the top of what ever I am doing at the time. I then have to wait 5 or so seconds for it to finish and self-close or I have to minimize it. Is there a way to stop this from happening?

    Thank you for the help!

    Josh

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2024-07-09T17:30:47+00:00

    thank you for saying this! I have been struggling with windows 11 reboots have tried 5 different things that dont work at all.

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2024-06-28T09:46:44+00:00

    I made the batch file shorter (BTW: I am the the original author of this fix. I can't get into my old username )

    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
    

    Was this answer helpful?

    3 people found this answer helpful.
    0 comments No comments