Scheduling Sleep Mode via the Task Scheduler
InformationThis 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.
The ScriptCode: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
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",Scripts from the Energy Star website.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