Automatic Sleep following Logoff (AKA One-click Log off & Standby)


  1. Posts : 8
    Win 7 Pro 64 bit
       #1

    Automatic Sleep following Logoff (AKA One-click Log off & Standby)


    This topic had been covered before in another thread posted last year, but the solution referred to still required me to do a fair bit of digging and playing to be able to get it to work as I wanted. So, to help others that may want to do the same, I thought I’d provide a consolidated “How To” on this. Since I’m a novice to most of the techniques used here I’ve covered the basics for those who may be in the same position - so for you experts out there please forgive the sound of sucking eggs!

    There is one caveat to this solution – I was hoping that this post would be providing a complete solution. There is however one niggle that I don’t have an answer to and am requesting suggestions. See the last section below.

    The “Problem”

    I have a home PC (running Windows 7 Pro 64) with four accounts (each without passwords). I want to have the PC to go into Sleep most of the time instead of Shutting Down. If, from one of the accounts, you put the PC into Sleep then, when it wakes, it does not present the normal Logon screen with all accounts - it just shows a logon for the last account (which is logical since you may have had programs open). However, if it’s not the account you want, you have to go into the account, logoff and then go into the account you want (or switch user).

    The Logoff and Sleep can obviously be done by logging off and then selecting Sleep from the options on the login screen. But I find that this two-click process is far too much effort and I was keen to find a single click solution! I was also keen to find a solution that did not use any third party utilities.

    To me this function makes absolute sense. Why would you want the machine to sit there in the logon screen without going into a power saving mode almost immediately. And as far as I can see there’s no way of setting the power saving mode for the logon screen separately.

    Credit Where Credit’s Due

    As I mentioned, this had been covered in a previous thread on this forum:

    https://www.sevenforums.com/general-discussion/193750-log-off-standby-1-click.html

    Which had a link to:

    http://www.donationcoder.com/forum/index.php?topic=28490.msg266669#msg266669

    And credit to this solution really goes to 4wd and other contributors on that forum.

    The Principle

    I had a couple of problems with the solution as defined in those threads. First, it had a prerequisite that the user account had a password and, secondly, it required the use of a shortcut on the desktop to perform the Logoff/Sleep function rather than using the normal Logoff function from the Shutdown button. So I’ve refined it a bit.

    The basic principle is to use Task Scheduler to set a task to force the computer to go into Sleep 30 seconds after someone logs off. It also has a task that kills the automatic Sleep if another user logs on within the 30 seconds (this is the main refinement since the previous solution was to use batch files to enable and disable the task).

    If passwords are not used then the set up of the tasks requires you to disable the password requirement using the Local Administrative Tools

    And finally, you have to completely disable Hibernation. Without doing this then the PC will go into Hibernation instead of Sleep.

    The Process

    The process to set this up takes a few minutes and requires the following five steps (which are detailed in the attached PDF):

    1. Disable Hibernation
    2. Disable Password requirement for the Tasks (if passwords not used)
    3. Set Up a Task for Delayed Sleep triggered from a logoff (LogoffSleep task)
    4. Set up a Task to Kill the LogoffSleep task if someone logs back in (LogoffSleepKill task)
    5. And, if you want, change the default Shutdown button to Logoff

    So, if you want to try the Logoff/Sleep function, follow the instructions and test it out. Then feed back any issues – although I doubt if I’ll be able to come up with the answers but I’m sure there’ll be others here who will be able to help!


    And a few questions for the experts

    The niggle I have with the set up described here is that if you have to do a shutdown to install updates, the computer logs itself off and then hangs on the log-off screen whilst it does the updates – this can invariably take longer than 30 seconds. The computer will therefore be forced into a sleep during this update. Now this has happened to me and when you wake the computer up it appears to complete the update without apparent complaints. What I would really like to know if there is any way of detecting that this is happening and prevent the sleep kicking in. I could resort to using a batch file to disable the Task before doing the shutdown but it's not very elegant (since you'll then ahve to re-enable it (can you use a task to enable another task? If you can then you can use this to enable it at logon))

    Also, can any of you see other issues with the process describe here? Specifically any issues related to disabling the password requirement for the scheduled tasks. There’s obviously a chance that if, once someone’s logged out, there’s a delay in another person logging on there’s slim chance that the LogoffSleep task could be triggered half way through the login process and just before the LogoffSleepKill task stops it. It’s a remote possibility but do you think this would be an issue?

    And finally, some information I could not track down was a list of all Event IDs for Winlogon process or any specific reference info for powrprof.dll. If anybody can oblige I’d appreciate it.

    _
    Automatic Sleep following Logoff (AKA One-click Log off & Standby) Attached Files
      My Computer


  2. Posts : 5
    xp and seven
       #2

    i wanted hybrid sleep enabled, so i used a .bat file with psshutdown from systernals

    shutdown /l
    psshutdown -d -t 0 /accepteula

    the thing is, it goes to sleep, then when waked up it finishes logging off , but it's fast enough to be no problem, on an old atlhon 64 3000 single core. No need to disable hibernation so hybrid sleep is enabled, which is crucial for me. Also no need to do extra stuff so that's a plus.
      My Computer


  3. Posts : 1
    W8.1/64
       #3

    Thanks for this Manual!
    I was searching for exactly this situation :)
      My Computer


  4. Posts : 1
    Windows 7 Home Premium 32bit
       #4

    Thanks for the detailed instructions - exactly what I wanted.

    The one niggle you say you have with your solution is the issue that if you have to do a shutdown to install updates, the computer logs itself off and then hangs on the log-off screen whilst it does the updates – this can invariably take longer than 30 seconds. The computer will therefore be forced into a sleep during this update.

    This problem has been solved here.

    All you need do is replace the Program/script in step 3 c) of your detailed instructions with the batch file from the link indicated above. The batch file will delay the commencement of Sleep by a further period of time if it detects the Windows Update process running. If Windows Update finishes during this waiting period, then Sleep will commence. If Windows Update exceeds the waiting period, then the batch file ends without doing anything. As it stands, the batch file will wait 25 seconds. The line timeout.exe /t 4 /nobreak controls the waiting period. E.g. changing /t 4 to /t 5 will increase the waiting period by 5 seconds.
    Last edited by 1geoff99; 15 Jul 2014 at 03:47.
      My Computer


  5. Posts : 8
    Win 7 Pro 64 bit
    Thread Starter
       #5

    1geoff99 said:
    Thanks for the detailed instructions - exactly what I wanted.

    The one niggle you say you have with your solution is the issue that if you have to do a shutdown to install updates, the computer logs itself off and then hangs on the log-off screen whilst it does the updates – this can invariably take longer than 30 seconds. The computer will therefore be forced into a sleep during this update.

    This problem has been solved here.

    All you need do is replace the Program/script in step 3 c) of your detailed instructions with the batch file from the link indicated above. The batch file will delay the commencement of Sleep by a further period of time if it detects the Windows Update process running. If Windows Update finishes during this waiting period, then Sleep will commence. If Windows Update exceeds the waiting period, then the batch file ends without doing anything. As it stands, the batch file will wait 25 seconds. The line timeout.exe /t 4 /nobreak controls the waiting period. E.g. changing /t 4 to /t 5 will increase the waiting period by 5 seconds.
    Thanks for the feed back and answer to my question.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About 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 02:56.
Find Us