I want khổng lồ make a batch file that will sleep my computer after a period of time.

Bạn đang xem: How do i make a hibernation batch file?

The closest thing I have found is placing it in standby, but seems to lớn work differently than the sleep button on my keyboard (longer bootup, doesn"t wake on mouse click). Any ideas? Would it be easier in Python or C#?

The less then ideal technique mentioned above is calling this in the cmd prompt:

Rundll32.exe powrprof.dll,SetSuspendState



Simply command

rundll32.exe powrprof.dll,SetSuspendStateDoes system hibernate, but if you write this:

rundll32.exe powrprof.dll,SetSuspendState 0,1,0And turn off hibernation with command:

powercfg -hibernate offNow your system will go asleep, và will wake up on mouse move if selected a device for it (scroll down lớn learn how).

Batch a timer:

timeout /t 1200rundll32.exe powrprof.dll,SetSuspendState 0,1,0Where 1200 is seconds, which mean after 20 minutes batch will run sleep command.

Optionally you can prevent canceling countdown (if you press any key in batch window):

timeout /t 1200 /nobreakrundll32.exe powrprof.dll,SetSuspendState 0,1,0Little HOWTO about waking up with mouse:

Go to: Start -> Control Panel -> Mouse.


In the Mouse Properties window, click on the Hardware tab và select your mouse from the menu of devices. Normally, there will only be one mouse listed here but that will depend on the hardware you have connected to lớn your computer. When you have selected your mouse from the list, click the Properties button.


Now in the Properties window for your mouse, click on the Change Settings button on the General tab.

Xem thêm:


In the window that opens, click the Power Management tab and check the option titled Allow This Device to Wake The Computer. Click the OK button on this window và click the OK button on the Mouse Properties windows that is still open.From now on, you can wake up Windows 7 from sleep mode by clicking a mouse button or moving the mouse around.