Windows 10 machine keeps waking from sleep

This has been a source of irritation for many recently.  Simply disabling wake timers and disabling the Windows Update service is no longer enough to keep Microsoft from waking your machine from sleep mode to carry out maintenance and install updates.  It looks like this was introduced as an update sometime in 2018 and affects Windows 10 1607, 1703 and 1709.  Fortunately there are a number of steps you can take to stop Microsoft meddling with your machine and leaving it running all night costing you larger electrical bills.

Disable wake timers

Here is a script designed to stop everything Microsoft has designed to wake your machine.  Simply save as a .ps1 file (eg. DisableWakeTimers.ps1) and run in an administrative Powershell window.

# disable wake for enabled scheduled tasks that are allowed to wake
Get-ScheduledTask |
?{ $_.Settings.WakeToRun -eq $true -and $_.State -ne 'Disabled' } |
%{
    write-host $_
    $_.Settings.WakeToRun = $false;
    Set-ScheduledTask $_
}

# disable wake for devices that are allowed to wake (list of wake capable devices: powercfg -devicequery wake_from_any)
powercfg -devicequery wake_armed |
%{
    write-host $_
    if ($_ -notmatch '^(NONE)?$')
    { powercfg -devicedisablewake $_ }
}

# disable wake timers for all power schemes
powercfg -list | Select-String 'GUID' |
%{
    write-host $_
    $guid = $_ -replace '^.*:\s+(\S+?)\s+.*$', '$1'
    powercfg -setdcvalueindex $guid SUB_SLEEP RTCWAKE 0
    powercfg -setacvalueindex $guid SUB_SLEEP RTCWAKE 0
}

# disable wake for automatic updates and for automatic maintenance
'HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\AUPowerManagement', 
'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\Maintenance\WakeUp' |
%{
    write-host $_
    $key = split-path $_
    $name = split-path $_ -leaf
    $type = 'DWORD'
    $value = 0
    if (!(Test-Path $key))
    { New-Item -Path $key -Force | Out-Null }
    if ((Get-ItemProperty $key $name 2>$null).$name -ne $value)
    { Set-ItemProperty $key $name $value -type $type }
}

Disable Scheduled Tasks

The next step is to open Task Scheduler and disable all tasks under WindowsUpdate and UpdateOrchestrator.

Stop-Windows-10-Machines-Waking-From-Sleep

Disable Windows Update (Optional)

If like me you like to be in control of how and when your machines are update I prefer to prevent automatic updates (particularly feature updates).  Quite often my machines have been rendered useless by a bad update or a change in the way Microsoft does something.  To prevent Microsoft re-enabling Windows update on your machine open Services as an administrator.  Find the Windows Update Service and set it to Disabled using the drop down box.

Stop-Windows-10-Machines-Waking-From-Sleep-1

Then click the Log On tab and change the account to Guest as below with no password, then click OK.

Stop-Windows-10-Machines-Waking-From-Sleep-2

Leave a Reply

Your email address will not be published. Required fields are marked *