2
3
How can I use Task Scheduler to put Windows 10 to sleep at a specific time without using a batch file?
2
3
How can I use Task Scheduler to put Windows 10 to sleep at a specific time without using a batch file?
5
Set up your time in Task Scheduler's Triggers window as normal. On the General tab, it's probably easiest to make the task run as SYSTEM
, and run whether the user is logged in or not. Highest privileges are not necessary.
Since rundll32
is deprecated and treacherous in general, we'll use PowerShell to invoke the sleep function correctly. Set the Program/script field to powershell.exe
. Put this in the Add arguments field:
-command add-type -assemblyname System.Windows.Forms; [System.Windows.Forms.Application]::SetSuspendState([System.Windows.Forms.PowerState]::Suspend, $false, $false)
The add-type
command imports the Forms assembly, which contains a managed SetSuspendState
method. The second command calls that method, putting the computer to sleep but allowing wake events to exit sleep. (If you don't want wake events to keep working, change the last $false
to $true
.)
This works fine for sleeping, but how can I wake it from this sleep? Also with task scheduler. – Alex Bartiş – 2017-12-04T13:08:52.247
@AlexBartiş Though I haven't tested it, this HTG guide looks promising.
– Ben N – 2017-12-04T16:09:11.277thanks, I've tried it before asking you, and it doesn't work for me. I'm on the latest W10 Home Edition, and it doesn't work if I manually put it to sleep or if I use your task to put it to sleep. – Alex Bartiş – 2017-12-04T20:14:35.960
@AlexBartiş Hmm, in that case, I would suggest asking a new question with that information, as you have done. Hopefully somebody knows the answer. – Ben N – 2017-12-05T01:19:00.597
If anyone's still interested, here's an alternative way of scheduling. https://www.groovypost.com/howto/schedule-wake-sleep-windows-automatically/
– anonymous coward – 2018-05-29T20:21:24.7131
Note, for windows 10 this method has same bug not having the standby feature so it won't wake your computer if you also schedule that on your task scheduler. Use Sysinternals Pstools : https://stackoverflow.com/questions/32360306/sleep-via-shortcut-causes-schedule-tasks-to-not-wake-computer
– zcahfg2 – 2019-01-19T15:55:02.6400
The "Program/script" value should be: rundll32.exe The "Add arguments (optional):" value should be: powrprof.dll,SetSuspendState sleep The "Start in (optional):" value should be left empty.
IT IS IMPORTANT TO OBSERVE THE CASE OF THE "SetSuspendState" argument! "setsuspendstate" won't work!
2Danger! rundll32
is deprecated. Also, sleep
is not a valid argument to SetSuspendState
, which only takes three Booleans. Therefore, passing a string works only by chance, and probably demolishes the function's stack. – Ben N – 2016-04-26T13:11:53.653
http://superuser.com/questions/42124/how-can-i-put-the-computer-to-sleep-from-command-prompt-run-menu – Ƭᴇcʜιᴇ007 – 2016-04-26T14:53:59.860