I got fed up with my PC waking from sleep apparently at random intervals and did all the usual stuff, disabling wake timers, task schedules, disallowing LAN and other devices, running powercfg /sleepstudy etc. to no avail.
I found some scripts to disable all wake timers and ran that:
Get-ScheduledTask | ? { $_.Settings.WakeToRun -eq $true -and $_.State -ne "Disabled"} | % { $_.Settings.WakeToRun = $false; Set-ScheduledTask $_ }
Unfortunately, I also ran a script to disallow any device to wake the PC which appears to stall the sleep command until a key press and then shuts it down completely:
(/F "tokens=*" %A in ('powercfg -devicequery wake_armed') do powercfg -devicedisablewake "%A"
This produces several errors.
Although I can understand much of it, I don't have the programming skills to write a script to correct it :-(
Can anybody on here help? (can't restore a system image at the moment - I lent my backup drive+caddy to a buddy who's away)(OK - I'm a Muppett)
EDIT:
OK - I ran
PS C:\WINDOWS\system32> @echo off
for /F "tokens=*" %%A in ('powercfg -devicequery wake_armed') do (powercfg -devicedisablewake "%%A")
which gave an error of a missing '(' after keyword 'for'. So, I put one in:
PS C:\WINDOWS\system32> @echo off
for (/F "tokens=*" %%A in ('powercfg -devicequery wake_armed') do (powercfg -devicedisablewake "%%A").
This appears to have worked, although I still don't understand why, because there appears to be one '(' too many.
EDIT 2
Is there a way to reverse it? Can I just replace -devicedisableawake with -deviceenablewake ?
No comments:
Post a Comment