Menu Close

Prevent Windows 11 From Starting Up on Its Own from Hibernate or Sleep

Where the sleep functionality stores the state of the computer into RAM (Random Access Memory), hibernate stores the state on the hard drive, so it can be turned off without consequences for your current workflow. Without power, the data storage on the RAM will be lost. When sleeping, the computer is technically still turned on with low power consumption to keep its current state in the RAM.

When I switched to Windows 11 a while ago, I noticed that the hibernate functionality was not present, but I found out it can still be switched on in the settings:

Control panel > Hardware and Sound > Power Options > System Settings

If you manually navigate to these settings, at the Power Options page, you have to click on the “Choose what the power buttons do” button at the left. The hibernate checkbox will be present behind that click.

Making use of sleep and hibernate both, I occasionally found my computer to awaken on its own without my consent. Annoyingly, sometimes this happened at around 2:00 (2:00 AM that is), not usually a time I want to use my computer. So, how to prevent Windows 11 from starting up on its own from hibernate or sleep?

At the end of this post, I included a PowerShell script that executes all counter measures for you automatically (except for PowerToys). I’m frankly surprised there is no out-of-the-box setting in Windows that prevents this behavior altogether.

The following settings/configurations can prevent the computer from booting up on its own:

Fast startup

Uncheck Turn on fast startup (recommended) in System Settings:

Control panel > Hardware and Sound > Power Options > System Settings

If you cannot change the settings, be sure to click Change settings that are currently unavailable first.

Power settings / wake timers

One step back at Power options, we can edit the power plan settings. Do this for the current active plan by clicking on Change plan settings and then Change advanced power settings.

In the Power Options popup, expand +Sleep > Allow wake timers and set Setting on Disable.

Hardware that has the right to wake the computer

We can use PowerShell to check which devices have this right, open a PowerShell window and:

powercfg -devicequery wake_armed
PowerShell

These devices can be found at the device manager. Uncheck Allow this device to wake the computer.

Right click Windows start menu > Device manager > Right click the device > Properties > Power Management

The same can be done for network adapters, mice, and possibly other devices.

Maintenance setting

If you open the Settings in Windows 11 and type in Security and maintenance, there is another setting that is able to wake up the computer on its own. This opens up:

Control Panel > System and Security > Security and Maintenance

Click on Maintenance > Change maintenance settings and uncheck Allow scheduled maintenance to wake up my computer at the scheduled time

Task Scheduler

The Task Scheduler, not to be confused with the Task Manager, is a list with automated tasks where some of them have the right to start up your computer to execute their configured task. The Task Scheduler can be found at Computer Management:

Right click Windows start menu > Computer Management > Unfold System Tools

If you unfold:

Task Scheduler Library > Microsoft > Windows

You will see quite an extensive list with directories, each of which can have multiple scheduled tasks. It will be tedious to find and disable the ones that can wake up the computer.

The following PowerShell Script can help identify the culprits:

$tasks = Get-ScheduledTask | Where-Object {$_.Settings.WakeToRun -eq $true}

foreach ($task in $tasks) {
    Write-Host $task
}
PowerShell

PowerToys

If you have Microsoft PowerToys installed, you should also check if the Awake settings (Enable Awake) is enabled or not. I would recommend disabling it if the startup problem persists. The script below does not include this.

Be aware that the responsibility when using code from online sources (such as this), lies exclusively by yourself.

When executing this code, you need to open up a PowerShell windows with Admin rights. Then you need to have an execution policy that allows you to make certain changes. Setting the ExecutionPolicy to Unrestricted makes sure that all PowerShell scripts are allowed to run. RemoteSigned should suffice if you input it yourself.

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
PowerShell

The script is verbose, but gives you feedback about how its process is going.

# Turn off fast startup
Write-Host -ForegroundColor Cyan 'Trying to turn off fast startup in registry'
 
try {
    $reg = [Microsoft.Win32.RegistryKey]::OpenBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, [Microsoft.Win32.RegistryView]::Registry64);
    $key = $reg.OpenSubKey('SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power', $true)
    if ($key.GetValue('HiberbootEnabled') -ne 0) {
        $key.SetValue('HiberbootEnabled', 0, [Microsoft.Win32.RegistryValueKind]::DWord)
        Write-Host -ForegroundColor Green 'Set to 0: ' $key
    }
    Write-Host -ForegroundColor DarkGreen -BackgroundColor White 'Already set to 0: ' $key        
}
catch {
    Write-Host -ForegroundColor Red -BackgroundColor Black 'Error: ' $_
}
 
 
# Turn off wake timers in power configuration
Write-Host -ForegroundColor Cyan 'Trying to turn off wake timers in power configuration'
 
$waketimers = powercfg -list | Select-String 'GUID'
 
if ($waketimers -ne $null) {
    foreach($waketimer in $waketimers) {
        try {
            $guid = $waketimer -replace '^.*:\s+(\S+?)\s+.*$', '$1'
            powercfg -setdcvalueindex $guid SUB_SLEEP RTCWAKE 0 # battery
            powercfg -setacvalueindex $guid SUB_SLEEP RTCWAKE 0 # plugged in power
            Write-Host -ForegroundColor Green $waketimer 'set to 0'
         }
        catch {
             Write-Host -ForegroundColor Red -BackgroundColor Black 'Error: ' $_
        }
    }
}
 
# Check for devices that can wake the system up
Write-Host -ForegroundColor Cyan 'Trying to turn off devices that can wake the system up'
$devices = powercfg -devicequery wake_armed
 
# Iterate over devices
if ($devices -ne $null) {
    foreach ($device in $devices) {
        if ($device -inotmatch 'NONE' -and $device -ne $null -and $device -ne '') {
            Write-Host 'Found device: ' $device
            try {
                powercfg -devicedisablewake $device
                Write-Host -ForegroundColor Green 'Disabled waking for: ' $device
            }
            catch {
                Write-Host -ForegroundColor Red -BackgroundColor Black 'Failed disabling waking for: ' $device
            }
        }
        else {
            Write-Host -ForegroundColor DarkGreen -BackgroundColor White 'No devices found that can wake the system up'
        }
    }
}
 
 # Turn off maintenance wake up
Write-Host -ForegroundColor Cyan 'Trying to turn off maintenance wake up'
 
try {
    $reg = [Microsoft.Win32.RegistryKey]::OpenBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, [Microsoft.Win32.RegistryView]::Registry64);
    $key = $reg.OpenSubKey('SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Schedule\\Maintenance', $true)
    if ($key.GetValue('WakeUp') -ne 0) {
        $key.SetValue('WakeUp', 0, [Microsoft.Win32.RegistryValueKind]::DWord)
        Write-Host -ForegroundColor Green 'Set to 0: ' $key
    }
    Write-Host -ForegroundColor DarkGreen -BackgroundColor White 'Already set to 0: ' $key        
}
catch {
    Write-Host -ForegroundColor Red -BackgroundColor Black 'Error: ' $_
}
 
     
# Get all tasks that have the wake to run setting turned on
Write-Host -ForegroundColor Cyan 'Checking for scheduled tasks that can wake the system up'
$tasks = Get-ScheduledTask | Where-Object {$_.Settings.WakeToRun -eq $true -and $_.State -ne 'Disabled'}
 
# Iterate over the tasks and disable the setting for each task
if ($tasks -ne $null) {
    foreach ($task in $tasks) {  
        try {
            $task.Settings.WakeToRun = $false
            $task | Set-ScheduledTask
            Write-Host -ForegroundColor Green 'Task succesfully changed: ' $task
        }
        catch {
            Write-Host -ForegroundColor Red -BackgroundColor Black 'Error while trying to change Task: ' $task
        }
    }
}
else {
    Write-Host -ForegroundColor DarkGreen -BackgroundColor White 'No tasks found in the scheduler that have to right to start up the computer'
}
PowerShell

To prevent your computer from waking up at all, you can use the PowerShell script to disable possible culprits on your computer that do so. Or you can choose to disable them manually.

The script is also available on github. (Use at own risk)

After extracting the script (or cloning it with git), import the SystemWakeUp module in a PowerShell terminal, and call the Disable-SystemWake cmdlet:

Import-Module .\Modules\SystemWakeUp\SystemWakeUp.psm1
Disable-SystemWake
PowerShell

Output:

Related Posts