Use Windows Task Scheduler To Put Windows To Sleep Without Batch File
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
.)