Schedule Sleep to Your Windows Computer

Schedule sleep to your Windows computer. As you know powershell is strong tool in Windows operating system. I need to script as start sleep my computer on a spesific time.  And i wrote it.

You can schedule to your computer as shutdown easly there is many more option for that.  But if you want to sleep insted of shut your pc down there is not so alternative.

Here is the powershell script you can schedule sleep your computer. Just save it as ps1 file and run it when do you need to schedule sleep.

Powershell Schedule Sleep Script

#This script start to sleep your computer after minutes that you indicate
$time = Read-Host "Please insert time to sleep as minutes"
$time2 = ([uint32]$time * 60)

Start-Sleep -Seconds $time2
rundll32.exe powrprof.dll, SetSuspendState Sleep

Note: This command is not exact sleep mode. When you run the script, hibernate mode will on your computer (Consume very less energy). If you want to start your computer have to push power button (Not keyboard, mouse movement etc)

If you need to exact sleep mode instead of hibernate, you can do it with psshutdown.exe tool that tools of Sysinternals

Download From Here:

  1. Put The PsShutdown.exe into C:\Windows\System32\
  2. Open your notepad and put the below command
  3. psshutdown.exe -d -t 0 -accepteula (The “-accepteula” Is To Accept The Terms Screen That Pops Up When Executing psshutdown.exe -d -t 0 )
  4. And Save Your notepad as cmd File (sleep.cmd)