Make Windows 7 go to sleep after x seconds

A one-liner (based of DavidPostill's accepted answer):

timeout /T 3600 & rundll32.exe powrprof.dll,SetSuspendState 0,1,0

To be sure it works, you can try it like this:

timeout /t 10 & notepad

the Notepad should open after 10 seconds.

Important note: If you have git installed on your computer, its bin folder might be in the PATH, and doing timeout in the command line will run C:\Program Files\Git\usr\bin\timeout.exe instead of the default C:\Windows\System32\timeout.exe! In this case you have to include the full path of timeout, in order to use the Windows timeout tool.


How do I make Windows 7 go to sleep after x seconds?

Use the following batch file, and run as an Adminstrator

@echo off
rem disable hibernate
powercfg -hibernate off
rem wait x seconds, eg 1 hour
timeout 3600 /nobreak
rem sleep
%windir%\System32\rundll32.exe powrprof.dll,SetSuspendState 0,1,0

Further Reading

  • An A-Z Index of the Windows CMD command line
  • A categorized list of Windows CMD commands
  • powercfg - Control power settings, configure Hibernate/Standby modes.
  • timeout - Delay execution for a few seconds or minutes, for use within a batch file.