/ Published in: DOS Batch
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.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
@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: " 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. choice /c:yn /n /t 5 /d y /m "Do you really want to sleep? y/n: " echo Sleep cancelled. goto end echo ~SLEEP~ | rundll32.exe powrprof.dll,SetSuspendState 0,1,0 ) goto end :end echo TASK DONE exit /b