Revision: 58204
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 1, 2012 06:24 by Rectifier
Initial Code
@echo off @cls ::Tested on a Windows 7 x64 Home Premium machine, but invoking powrprof.dll should work on any xp/ ::server 2k3 machine and higher ::Script by Rectifier 06-30-2012 ::You WILL need to manually edit the sleepact label to include programs that interrupt sleep :sleepcheck set choice= set /p choice="Enter sleep mode? y/n: " if not "%choice%"=="" set choice=%choice:~0,1% if /i "%choice%"=="y" goto sleepact echo Did not choose yes!!! goto end ::Programs associated with internet traffic are typical culprits for interrupting sleep mode ::Of these programs, p2p file sharing programs such as utorrent definitely interrupt sleep mode ::MCE Standby Tool is a free program to figure out what is potentially blocking/stopping sleep mode ::Uncomment the example taskkill statments to use them! ::The taskkill command works by using the process name, not the name of the application itself :sleepact echo Killing off any netprogs! echo. ::taskkill /f /im utorrent.exe > nul 2>&1 ::taskkill /f /im mirc.exe > nul 2>&1 ::taskkill /f /im xchat.exe > nul 2>&1 ::taskkill /f /im Steam.exe > nul 2>&1 ::taskkill /f /im firefox.exe > nul 2>&1 ::taskkill /f /im chrome.exe > nul 2>&1 ::taskkill /f /im iexplore.exe > nul 2>&1 ::taskkill /f /im opera.exe > nul 2>&1 echo. echo Sleeping automatically in five seconds! echo. choice /c:yn /n /t 5 /d y /m "Do you really want to sleep? y/n: " set slstatus=%ERRORLEVEL% if "%slstatus%"=="2" ( echo Sleep cancelled. goto end ) ELSE ( echo ~SLEEP~ | rundll32.exe powrprof.dll,SetSuspendState 0,1,0 ) goto end :end echo TASK DONE ping 127.0.0.1 -n 2 | find "Reply" > nul exit /b
Initial URL
Initial Description
This is a fraction of a much larger script which does multiple tasks. This scriptlet is intended to be interactive and somewhat user-friendly. First, it asks if you want to place the computer into sleep mode, then it kills pesky processes associated with interrupting sleep mode, finally, if you want the batch to skip waiting you can press Y to immediately start the sleep sequence or press N to cancel at the last second.
Initial Title
Put windows to sleep (and keep it asleep!)
Initial Tags
windows
Initial Language
DOS Batch