Sleep Return Timeout for Unattended Wake Up

Page 6 of 6 FirstFirst ... 456

  1. Posts : 22
    Windows 7
       #50

    Another question for you, Brink:

    I can't figure out a way for my computer to force back to sleep, is there a way to make my computer wake-up (from a shut down state) at a specific time?? If you have a tutorial regarding this, let me know but I don't think I saw one.

    The reason I ask is that if I can wake-up my computer from a shut down state and clearly have way to force it shut down, this may be a work around. However, this somewhat works against the whole point of putting the computer in a sleep state.

    Thanks.
      My Computer


  2. Posts : 161
    Windows 7 Home Premium 64 bit
       #51

    kanungos

    You mentioned that the rundll32.exe powrprof.dll,SetSuspendState command shuts down your PC. Are you referring to a complete PC shutdown where you need to push your PC's power button in order to power up your PC after using rundll32.exe powrprof.dll,SetSuspendState ?

    I'm wondering if your PC is actually getting put into 'hibernate' mode. I have both of my Win 7x64 PC's 'hibernate' option disabled and have been using a "forced Sleep" action without problems for about 3 years.

    You might try disabling 'hibernate' in a CMD window. That usually needs to be disabled in order for the rundll32.exe powrprof.dll,SetSuspendState command to put the PC to Sleep mode (instead of 'hibernate' mode) if run from within a batch job or possibly the Task Manager.

    To disable 'hibernate', open an elevated CMD window.

    At the CMD prompt, enter this to check your current Sleep/Hibernate PC states:

    powercfg -a

    You should see something like this returned in system information. Here's my Desktop PC's current info when I use the "powefcfg -a" query:

    The following sleep states are available on this system: Standby ( S1 S3 )
    The following sleep states are not available on this system:
    Standby (S2)
    The system firmware does not support this standby state.
    Hibernate
    Hibernation has not been enabled.
    Hybrid Sleep


    if your 'hibernate' option is enabled, you can disable it with this command:

    powercfg -h off


    If my memory's working right, the rundll32.exe powrprof.dll,SetSuspendState requires the 'hibernate off' command to be included in a batch file in order for the command to put the PC into Sleep mode and not 'Hibernate' mode. That also requires the batch file to be run in "Admin" (elevated" mode.


    Another option for you to use with Task Scheduler to force the PC to Sleep mode, is to use a free utility from one of the "Sysinternals" tools called "psshutdown".

    Here's the link to the "psshutdown" download site that can be used to do what you're wanting to do with your PC.

    psshutdown v2.52

    It's a standalone .exe file that can use used to put the PC to Sleep mode with a batch file or a Task in Task Manager.

    The "-d" parameter is the one that puts the PC to Sleep mode.

    For example, included is a screencap from a "Sleep Test" task that I created and tested on my PC.

    I have my "psshutdown" exe file in my top C: directory so I entered that in the "program/script" field.

    Then you add the "-d" parameter in the "add arguments" field.

    The "-t 30" parameter is a time-delay (30 seconds in this example) that you can use to delay the psshutdown exe file from putting the PC to sleep. I think the default time delay value is 20 seconds.

    I ran this Task in my Win Task Scheduler a couple of times and it worked ok.


    I've been running my "Sleep" task another way using a freeware hotkey/script program called "AutoHotKey". Within AutoHotkey, there's a command that will put the PC to sleep:

    DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0)

    I'm using it in a way that's similar to what may be what you're wanting to do with your PC.

    For example,

    I have a daily specific-item backup job that runs unattended at 12:00pm on my PC. The job takes about 1-2 minutes to complete.

    At 12:05pm, my "Sleep" task runs which puts the PC back to sleep. I've been running this for about 3 years without issue.
    Attached Thumbnails Attached Thumbnails Sleep Return Timeout for Unattended Wake Up-task-actions.png  
      My Computer


  3. Posts : 22
    Windows 7
       #52

    Hi Scoop,

    Thanks for your reply.

    In answer to your first question, as far as I can tell, it appears to be a complete shut down of my PC when rundll32.exe powrprof.dll,SetSuspendState "task" runs via my Windows Task Scheduler -- I do need to push the power button to get the PC going again.

    Should I still try and disable the hibernation option and see what happens?

    If that fails, should I then consider your "psshutdown" and "autohotkey" options??

    Let me know and thanks for your advice once again.

    Tim
      My Computer


  4. Posts : 161
    Windows 7 Home Premium 64 bit
       #53

    Tim,

    That's strange, the PC shutting down using rundll32.exe powrprof.dll,SetSuspendState .

    I've never seen that occur with my Desktop PC. My Laptop PC is a backup PC so I'm not using it much to test things like this but I got curious about it and tried it on my Laptop PC. The results are interesting.

    Is your PC a Desktop or Laptop? If it's a Laptop, then the 'hibernate' mode being enabled may be what you're seeing as I just ran a test on my Laptop PC (Toshiba Laptop) with 'hibernate' disabled and enabled using the rundll32.exe powrprof.dll,SetSuspendState command. Here are the results:

    I opened a CMD window and disabled 'hibernate' mode in CMD.

    I then entered the rundll32.exe powrprof.dll,SetSuspendState command in the CMD window.

    The PC went into normal Sleep mode, requiring any key pressed, etc, to awaken the PC. (PC power button not required to awaken the PC).

    After awakening the PC, I enabled 'hibernate' on my Laptop PC and repeated the rundll32.exe powrprof.dll,SetSuspendState test in CMD .

    The PC went into 'hibernate' mode which required the power button on the Laptop to be pressed to wake the PC (take it out of 'hibernate' state) since 'hibernate' is sort of like a partial restart, as the PC's environment is saved to the HDD when invoking the 'hibernate' mode so any workspace/windows, etc, that were open and in use at the time the PC went into 'hibernate' state, will be resumed once the PC is awakened.


    This is why I like using my AutoHotKey script since the rundll... command is dependent on the 'hibernate' state and the Sleep script command is not dependent on whether 'hibernate' is enabled or disabled.


    If the CMD (rundll...) test still shuts down the PC instead of going into Sleep mode, you might want to verify that the manual interactive "sleep" function is working ok on your PC (see next).

    Does your PC go into Sleep mode and not shut down when you click on the Sleep option from your Start menu power button?

    You can also verify the Sleep mode from the Windows Shutdown Menu like this:

    - Put your PC in Desktop/active mode (close all other apps, windows).

    - Hold down the <alt> key while pressing the F4 key. You should see the Windows Shutdown Menu appear (see included screencap).

    - Select the Sleep Mode and verify that your PC goes into Sleep and not a complete shutdown state.

    If that works ok, you might try the "psshutdown" download exe file.

    Once you have extracted the zip folder download, you'll see several files in the folder. Move just the "psshutdown" exe file into your C: directory.

    To test the Sleep mode using psshutdown,

    - Open an elevated CMD window.

    - Disable "hibernate" mode if it's not already disabled:

    hibernate -h off

    Enter this at the CMD prompt:

    cd \ (this changes your default directory location in CMD to your C: directory where your psshutdown file is located).

    Then, enter this:

    psshutdown -d -t 30

    Your PC should go into Sleep mode in 30 seconds.

    If that works, that should verify that the basic "sleep" command and your power configurations are working ok.

    it should also then work from within the Task Manager as a Task.
    Attached Thumbnails Attached Thumbnails Sleep Return Timeout for Unattended Wake Up-shutdown-menu.png  
      My Computer


  5. Posts : 22
    Windows 7
       #54

    Hi Scoop,

    Actually you were right -- my computer was going into "hibernate" mode with the rundll32.exe powrprof.dll,SetSuspendState command. I really have never used hibernate for much of anything since this is all being done on my Desktop.

    Hibernation appears very similar to shutdown to the untrained eye (like me!)

    Anyway, I disabled the hibernation mode in the elevated CMD and now things seem to be working as they should be with my computer going into sleep mode.

    Another question for you -- will there be any issue or problem with keeping the hibernation mode disabled on my Desktop PC?? As I said, I seen the benefit of the mode on a laptop but not much so on a Desktop.

    Thanks.

    Tim
      My Computer


  6. Posts : 161
    Windows 7 Home Premium 64 bit
       #55

    Tim,

    Glad it's working ok now.

    Here's a link to one of Shawn's ("Brink") tutorials at this site that explains the differences with the "Sleep" states and "Hibernate".

    Sleep States - See Available Sleep States

    As for "Hibernate", I don't use it myself because I'm always at "Desktop/idle" mode when I invoke Sleep interactively or unattended with a Task or script.

    Since all of my apps/windows, etc, are closed when Sleep is launched, the Hibernate option isn't needed for my PC habits since I don't require my PC's environment to be saved to the HDD in the event of a power interruption occurring with my PC.

    if you routinely close your apps/files, etc, before you leave your PC (before you use the Sleep mode), then Hibernate isn't required from my POV.

    I've had my Hibernate disabled on my Desktop since 2010 without issues.

    I left it enabled on my Laptop but I don't use it as I also close any activities before invoking Sleep mode.

    "Untrained eye".... don't be concerned about that :). My "eye" is about as trained as a gnat compared to many contributors at this forum
      My Computer


  7. Posts : 22
    Windows 7
       #56

    Hi Scoop (or Brink if your still reading):

    I have another question for you:

    Since the rundll32.exe powrprof.dll,SetSuspendState command has been working as it should via my Windows Task Scheduler, I have noted something a little odd -- after the command has run, and later on, I "wake" my computer up (hit the keyboard or click on the mouse) and then leave it idle, it FAILS TO GO BACK TO SLEEP. My power plan is balanced and is set to go back to sleep after 15 minutes; however, it seems that IT IS NOT GOING BACK TO SLEEP after the 15 minutes elasped time.

    My understanding of what should happen is what Brink said at that the beginning of this original tutorial:

    "If the computer wakes up from sleep mode and is used by you (no longer idle) during this default timeout period, then Windows will not go back to sleep mode automatically after this timeout period. Instead it will use the time period you set in your Power Plan Settings for Sleep or Hibernation"

    Do you actually have to "work" on the computer (ie log in and then email, internet surf...etc) AND THEN LEAVE IT IDLE for the computer to fall back asleep or is there something else I am missing.

    As always, thanks for your help.

    Tim
      My Computer


  8. Posts : 72,046
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #57

    Hey Tim,

    Used basically means any activity caused by the user. This could be as simple as the mouse moved. Say by a cat playing with it.
      My Computer


 
Page 6 of 6 FirstFirst ... 456

  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 15:43.
Find Us