Wake History Count - 1
Wake History [0]
Wake Source Count - 1
Wake Source [0]
Wake History Count - 1
Wake History [0]
Wake Source Count - 0
(No Wake Source is shown)
If I press a key to wake my computer from the sleep mode, the result will be the one shown in screenshot 1.
If the computer wakes up unexpectedly, the result will be the one shown in screenshot 2.
I have tried various methods, but there is actually no way to prevent the computer from waking up unexpectedly.
The problem did not arise until I upgraded my Windows 7 to Windows 10 last month, so I think the problem lies in Windows 10 instead of my computer, to which no hardware changes have been made.
In Event Viewer, the events that happen when it wakes up unexpectedly are exactly the same as those that happen when it wakes up normally (i.e. I wake it manually)
In Power settings, under Conditions, waking the computer to run the task has been disabled.
By means of Task Scheduler, a .bat file can be run automatically whenever the computer wakes up, whether unexpectedly or normally.
What commands can be used in the file so that the computer will automatically go to sleep again whenever it wakes up unexpectedly?
Answer
Try this:
powercfg -lastwake | findstr /I /C:"Type:"
if %errorlevel% == 0 (
echo woken up by something
) else (
echo woken up unexpectedly
)
In short, it just looks for Type:
in the output of powercfg -lastwake
and if it doesn't exist then assumes that the machine woke up unexpectedly.
If you want to actually make the machine go back to sleep then replace the second echo
with the following:
powercfg -h off
rundll32.exe powrprof.dll,SetSuspendState 0,1,0
powercfg -h on
Bear in mind that your computer could get into a loop where it wakes, runs this script, goes back to sleep, wakes, runs this script, goes back to sleep and so on and so on.
No comments:
Post a Comment