Windows 7 Forums


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 05 Apr 2010
Published by

Featured Tutorial

Microsoft Account - Sign up for and Create
Microsoft Account - Sign up for and Create

How to Sign up for and Create a Microsoft Account

Troubleshooting Steps for Windows 7
Troubleshooting Steps for Windows 7



Screen Capture and Video Editing in High Quality
Screen Capture and Video Editing in High Quality



Peppermint3 - Create Live CD/DVD/USB To Use For Emergency Backup
Peppermint3 - Create Live CD/DVD/USB To Use For Emergency Backup

How to Perform an Emergency Data Backup When Windows 7 Will Not Boot

Chrome GPU Hardware Acceleration - Turn On or Off
Chrome GPU Hardware Acceleration - Turn On or Off

How to Turn GPU "Hardware Acceleration" On or Off in Chrome

Clean Reinstall - Factory OEM Windows 7
Clean Reinstall - Factory OEM Windows 7

How to Clean Reinstall a Factory OEM Windows 7
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.


PsShutdown.exe

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.

Code:
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.
objShell.run "%windir%\psshutdown.exe -d -accepteula",
Code:
'** 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
Next
 
If Err = 0 Then
    If bLoggedOn Then
        WScript.Echo strComputer & " 
            is not Logged Off."
        bStandby = False
    Else
        WScript.Echo strComputer & " 
            is Logged Off."
        bStandby = True
    End If
Else
    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
    objShell.run "%windir%\psshutdown.exe -d -accepteula", 
        0, False
Else
    WScript.Echo "Not going into standby..."
End If
Scripts from the Energy Star website.






Need more help? Try searching our extensive help and support site.
Loading
19 Apr 2010   #1
RobertCShay

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
kferraro

XP, Vista
 
 
Beautiful!

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
Comment

 Task Scheduler - Put Computer into Standby Mode problems?



Tutorial Tools



Similar help and support threads for: Task Scheduler - Put Computer into Standby Mode
Windows 7 Tutorial Category
Task Scheduler - Create Task to Display a Message Reminder Tutorials
Task scheduler unable to load task status/active tasks at startup. Performance & Maintenance
Computer turns on, but screen doesn't with Task Scheduler General Discussion
Task Scheduler doesn't wake up computer Performance & Maintenance
Solved Task Scheduler failing to start task with merged network locations General Discussion


All times are GMT -5. The time now is 11:53 AM.


Seven Forums Android App Seven Forums IOS App Follow us on Facebook

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
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32