Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: Task Scheduler - Put Computer into Standby Mode

Task Scheduler - Put Computer into Standby Mode

How to Use Task Scheduler to Put Computer into Standby Mode
Published by not so gray matter
05 Apr 2010
Published by

Scheduling Sleep Mode via the Task Scheduler

information   Information
This tutorial shows you how to schedule your computer to go into Sleep Mode via Task Scheduler. It uses a combination of the program PSShutdown and VBScirpt. The advantages of using this instead of the Power Policy is that it can place logged off computers to sleep as well.


Download PsShutdown.exe. Now place it in the %windows% folder, or if you place it somewhere else, note that location so that you can change it in the script below.

Scheduling the Task

Here's an example of a task set to run every hour. If the user you're attempting to use this through doesn't have privileges, then you can use this as a group policy log on script.

To explore scheduling tasks options, type "schtasks.exe /?" without quotes in a command prompt. Use the client computer if scheduling through a group policy.

SCHTASKS.exe /Create /S %computername% /RU "SYSTEM" /ST 00:00:00 /SC HOURLY /SD 01/01/2007 /TN "StandBy" /TR "cscript.exe C:\ValidPath\standby-hibernate.vbs
The Script

This script relies on the fact that PsShutdown.exe is placed in the %windows% folder. The location of the program can be changed to anywhere as long as PsShutdown.exe exists there and the system account has access rights. If you do change the directory, find the following line in the script below and change %windir%\psshutdown.exe to reflect the new location. "%windir%\psshutdown.exe -d -accepteula",
'** Script Name: "standby-hibernate.vbs" **
Option Explicit
On Error Resume Next
Dim strComputer, sUserName, bLoggedOn, bReboot, objWMIService, 
    colComputer, objComputer
Dim bStandby, objShell
strComputer = "."
Set objShell = WScript.CreateObject("Wscript.Shell")
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer 
    & "\root\cimv2") 
Set colComputer = objWMIService.ExecQuery _
    ("Select * from Win32_ComputerSystem")
For Each objComputer in colComputer
    sUserName = objComputer.UserName
    'WScript.Echo "UserName:  " & objComputer.UserName
     If sUserName  <> "null" Then
         bLoggedOn = True
     End If
If Err = 0 Then
    If bLoggedOn Then
        WScript.Echo strComputer & " 
            is not Logged Off."
        bStandby = False
        WScript.Echo strComputer & " 
            is Logged Off."
        bStandby = True
    End If
    WScript.Echo "Error accessing computer:  " 
        & strComputer
    bStandby = False
End If    
On Error Goto 0
WScript.Echo "bStandby:  " & bStandby
If bStandby = True Then
    WScript.Echo "Going into standby..."
    'Go to standby "%windir%\psshutdown.exe -d -accepteula", 
        0, False
    WScript.Echo "Not going into standby..."
End If
Scripts from the Energy Star website.

19 Apr 2010   #1

windows 7 ultimate

Windows 7 Task Scheduler sleep command.

Well, I figured it out. To put a Windows 7 computer to sleep at a specified time using the Task Scheduler is a two step process.

First, you must disable the hibernation function. This can be accomplished with Admin rights on the CMD screen. See tutorial below:

Hibernate - Enable or Disable

Second, you need to use the following command in the Windows Task Scheduler:

Rundll32.exe Powrprof.dll,SetSuspendState Sleep

That is it!

My System SpecsSystem Spec
22 Apr 2010   #2

XP, Vista

Thanks Robert, your suggestion is exactly what I was looking for and follows my cardinal rule of KISS. I now have one task that wakes my computer to run a program for 3 hours and then a task to put it back into standby when the three hours is up. Perfect. Oh, this works on a Vista machine and probably will work on XP also.
My System SpecsSystem Spec
29 Oct 2013   #3

windows7 ultimate x32

Easy way to sleep:
rundll32.exe powrprof.dll,SetSuspendState 0,1,0
My System SpecsSystem Spec


 Task Scheduler - Put Computer into Standby Mode

Thread Tools

Similar help and support threads
Thread Forum
Task Scheduler Cannot Connect to the remote computer.
Hi. So, I have scoured the internet for the answer for my question, switched the scheduler from automatic to manual and back again, repaired files, merged new task schedule registry files into the old, cleared caches, rebooted many times, and nothing I have found so far has helped. Any...
Computer does not reliably enter Standby/S3 mode
EDIT: For anyone surfing on this issue and arriving here, be advised I've decided simply that the ancient motherboard in this computer simply did not work reliably with my SSD and so I've abandoned the effort. END EDIT I'd love if someone here would help me out. This PC does not reliably go into...
BSOD Help and Support
Windows XP Mode Crashes when waking up the computer from standby/sleep
I don't know why on earth it does that. This starts happening everytime now. Here are the details Problem signature: Problem Event Name: BEX64 Application Name: VMWindow.exe Application Version: 6.1.7601.17514 Application Timestamp: 4ce7b2e6 Fault Module Name: ...
Computer turns on, but screen doesn't with Task Scheduler
I was playing around with Task Scheduler to turn on laptop at specific time, it works great. However, while the system starts up just fine, the screen remains black until I touch the mousepad. Now that doesn't seem like a big deal, but what I was experimenting with is having the computer turn...
General Discussion
Task Scheduler doesn't wake up computer
Hi, I noticed somehow my username is logged off if the computer sleeps too long (like during night). If I test the task behind my computer and let the computer sleep for a short while, it automatically awakes. If I allow the computer sleep automatically and for long periods of time, then...
Performance & Maintenance

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 01:17.
Twitter Facebook Google+