+ Post New Thread
Results 1 to 12 of 12
Windows 7 Thread, Energy Saving for student project in Technical; I have been approached by a group of students from our eFutures initiative to try and reduce the power consumption ...
  1. #1
    cromertech's Avatar
    Join Date
    Dec 2007
    Location
    Cromer by the coast
    Posts
    731
    Thank Post
    177
    Thanked 109 Times in 97 Posts
    Rep Power
    55

    Energy Saving for student project

    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.

    Code:
    '** 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?

  2. #2
    jamesfed's Avatar
    Join Date
    Sep 2009
    Location
    Reading
    Posts
    2,214
    Thank Post
    138
    Thanked 347 Times in 293 Posts
    Rep Power
    90
    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).

  3. Thanks to jamesfed from:

    cromertech (22nd March 2011)

  4. #3

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,867
    Thank Post
    412
    Thanked 778 Times in 651 Posts
    Rep Power
    182
    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.

  5. Thanks to powdarrmonkey from:

    cromertech (22nd March 2011)

  6. #4
    cromertech's Avatar
    Join Date
    Dec 2007
    Location
    Cromer by the coast
    Posts
    731
    Thank Post
    177
    Thanked 109 Times in 97 Posts
    Rep Power
    55
    Quote Originally Posted by powdarrmonkey View Post
    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?

  7. #5

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,159
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    125
    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!

  8. #6
    cromertech's Avatar
    Join Date
    Dec 2007
    Location
    Cromer by the coast
    Posts
    731
    Thank Post
    177
    Thanked 109 Times in 97 Posts
    Rep Power
    55
    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?

  9. #7

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,824
    Thank Post
    371
    Thanked 544 Times in 507 Posts
    Rep Power
    184
    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

  10. #8
    cromertech's Avatar
    Join Date
    Dec 2007
    Location
    Cromer by the coast
    Posts
    731
    Thank Post
    177
    Thanked 109 Times in 97 Posts
    Rep Power
    55
    Quote Originally Posted by Steve21 View Post
    (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.

  11. #9

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,824
    Thank Post
    371
    Thanked 544 Times in 507 Posts
    Rep Power
    184
    Quote Originally Posted by cromertech View Post
    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" :P

    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 :P

    Steve
    Last edited by Steve21; 22nd March 2011 at 11:32 AM.

  12. #10
    cromertech's Avatar
    Join Date
    Dec 2007
    Location
    Cromer by the coast
    Posts
    731
    Thank Post
    177
    Thanked 109 Times in 97 Posts
    Rep Power
    55
    Quote Originally Posted by Steve21 View Post
    Was referring to sleep in CMD, aka so it lets log off complete before running the "sleep sleep" :P

    Else it'll sleep before logoff completes as OP mentioned

    * Edit -


    ^ Doesn't exist since Win 2k :P

    Steve
    My bad Completely misunderstood that.

  13. #11

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,824
    Thank Post
    371
    Thanked 544 Times in 507 Posts
    Rep Power
    184
    I blame MS! Silly people naming 2 items with same names :P

    Steve

  14. #12
    cromertech's Avatar
    Join Date
    Dec 2007
    Location
    Cromer by the coast
    Posts
    731
    Thank Post
    177
    Thanked 109 Times in 97 Posts
    Rep Power
    55
    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)



SHARE:
+ Post New Thread

Similar Threads

  1. Energy uses of ICT
    By paulpmp4 in forum General Chat
    Replies: 12
    Last Post: 9th September 2010, 02:42 PM
  2. Energy Saving
    By localzuk in forum General Chat
    Replies: 22
    Last Post: 14th June 2010, 10:03 PM
  3. Replies: 0
    Last Post: 19th May 2010, 10:12 PM
  4. Energy Prices
    By cookie_monster in forum General Chat
    Replies: 7
    Last Post: 12th June 2008, 02:03 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •