cromertech Posted March 22, 2011 Posted March 22, 2011 I have been approached by a group of students from our eFutures initiative to try and reduce the power consumption of our computer suites. They've noticed that they remain on during lessons when they are not used and so want to see if I can put them into standby when a user logs off. At first I thought this would be as easy as running a logoff script but that put the computer to sleep during the logoff process and when the computer was brought back the user logoff process had crashed. Has anyone managed to get this to work successfully, maybe with a scheduled task instead. I've found this script as well but I can get it to run as a student as yet as I get an undisclosed error and it just terminates. '** Script Name: "standby-hibernate.vbs" ** Option Explicit On Error Resume Next Dim strComputer, sUserName, bLoggedOn, bReboot, objWMIService, colComputer, objComputer Dim bStandby, objShell, sComputerName strComputer = "." Set objShell = WScript.CreateObject("Wscript.Shell") Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colComputer = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem") Do While sUserName <> "null" For Each objComputer in colComputer sUserName = objComputer.UserName sComputerName = objComputer.Name If sUserName <> "null" Then bLoggedOn = True End If Next Loop If Err = 0 Then If bLoggedOn Then WScript.Echo sComputerName & " is not Logged Off." bStandby = False Else WScript.Echo sComputerName & " 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%\System32\rundll32.exe Powrprof.dll,SetSuspendState 0", 0, False Else WScript.Echo "Not going into standby..." End If Any suggestions?
jamesfed Posted March 22, 2011 Posted March 22, 2011 Why not just set the machine to go into stand by after 5 mins of inactivity? It can be applied through the energy management GPOs and works on Windows XP+ (may need client side extensions but not too sure). 1
powdarrmonkey Posted March 22, 2011 Posted March 22, 2011 And for bonus points, configure the default profile and user profiles independently so that a logged-in user doesn't stood by after five minutes. 1
cromertech Posted March 22, 2011 Author Posted March 22, 2011 And for bonus points, configure the default profile and user profiles independently so that a logged-in user doesn't stood by after five minutes. Now that idea I like. It already logs them off after 20 mins of no activity (Using Impero policies). Could I do this with Group policy preferences instead with different settings for machine and user?
srochford Posted March 22, 2011 Posted March 22, 2011 What version of Windows? We had problems with XP where all sorts of things would wake it up. Windows 7 is much, much better at staying asleep!
cromertech Posted March 22, 2011 Author Posted March 22, 2011 All windows 7. They currently have a sleep time of 45 minutes and WOL is enabled to wake them just before a shutdown at the end of the day. Do you know whether GPP is just that (a preference) so that it will return to a previous state when the user logs off?
Steve21 Posted March 22, 2011 Posted March 22, 2011 If you want a crude, but simple version, Couldn't you just do LogOff Script : ping -n 10 127.0.0.1 > NUL 2>&1 %windir%\System32\rundll32.exe powrprof.dll,SetSuspendState (No sleep command in Win XP+ but you can cheat using delayed Ping command unless it's been nerfed recently. 10 seconds delay (or longer if slow logout, then it'll run hibernate) Should work, Steve
cromertech Posted March 22, 2011 Author Posted March 22, 2011 (No sleep command in Win XP+ Steve Not quite true rundll32.exe powrprof.dll,SetSuspendState 0 will put the computer into sleep. A value other than zero will result in hibernation.
Steve21 Posted March 22, 2011 Posted March 22, 2011 (edited) Not quite true rundll32.exe powrprof.dll,SetSuspendState 0 will put the computer into sleep. A value other than zero will result in hibernation. Was referring to sleep in CMD, aka so it lets log off complete before running the "sleep sleep" Else it'll sleep before logoff completes as OP mentioned * Edit - Sleep.exe: Batch File Wait Sleep is a command-line tool that causes the computer to wait for a specified amount of time. For use in batch files ^ Doesn't exist since Win 2k Steve Edited March 22, 2011 by Steve21
cromertech Posted March 22, 2011 Author Posted March 22, 2011 Was referring to sleep in CMD, aka so it lets log off complete before running the "sleep sleep" Else it'll sleep before logoff completes as OP mentioned * Edit - ^ Doesn't exist since Win 2k Steve My bad Completely misunderstood that.
Steve21 Posted March 22, 2011 Posted March 22, 2011 I blame MS! Silly people naming 2 items with same names Steve
cromertech Posted March 24, 2011 Author Posted March 24, 2011 Just a quick update on this. All is well. Computers go to sleep after 3 mins with no one logged in and never when someone is logged in. Students are automatically logged off after 20 minutes and staff after 1 hour 30 of inactivity but screens lock after 20 mins (yes staff forget to log out too thank heavens for locking screensavers)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now