How to prevent stand by/hibernation?-VBForums
Results 1 to 13 of 13

Thread: How to prevent stand by/hibernation?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    159

    How to prevent stand by/hibernation?

    My program requires that the computer remain on full power in order to operate, is there a way I can prevent the computer from entering any power saving modes like stand by or hibernation when it has scheduled tasks to do? I'd also like to allow power saving mode once no more scheduled tasks remain.

    Thank you

  2. #2
    PowerPoster
    Join Date
    Jan 2008
    Posts
    9,151

    Re: How to prevent stand by/hibernation?

    Start-->Settings-->Control Panel-->Power Options


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    159

    Re: How to prevent stand by/hibernation?

    Sorry, I meant that I want to know how to make my software itself prevent the system from entering stand by or hibernation if it has scheduled tasks.

    Thanks

  4. #4
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,644

    Re: How to prevent stand by/hibernation?

    i know nothing about that but i found this link which coule help you get started (api calls)

  5. #5
    PowerPoster
    Join Date
    Jan 2008
    Posts
    9,151

    Re: How to prevent stand by/hibernation?

    Works like a charm but it doesn't prevent your system from entering hibernation as written; it puts your system in hibernation and then wakes it up after a certain amount of time has elapsed.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  6. #6
    PowerPoster
    Join Date
    Jan 2008
    Posts
    9,151

    Re: How to prevent stand by/hibernation?

    OK, you can enable/disable hibernation from your VB app by changing a value in the Registry

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Session Manager\Power\Heuristics

    Code:
    Value is XX XX XX XX XX XX 00 XX XX XX ......... XX          00 = Hibernation disabled
    Value is XX XX XX XX XX XX 01 XX XX XX ......... XX          01 = Hibernation enabled
    Do not modify any of the other values XX; only the 7th value


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    159

    Re: How to prevent stand by/hibernation?

    Actually, if the software could let the computer enter standby/hibernation and then wake it up perhaps 5 minutes before a scheduled task that would be even better, but do all computers support being awakened once in these power saving modes? I have a very string feeling only more modern computers would support that.

    If that's the case I prefer the registry settings option. Can both Stand By and Hibernation be disabled and re enabled through registry and how? Also, once the registry changes are made do you need to somehow tell Windows "Hey look at the power settings, you shouldn't go in standby in 30 minutes like you normally do" or will it auto detect the changes?

    I also don't want to edit their default inactivity timeout for stand by or hibernation, do these registry settings simply prevent it from entering these modes or does it also change their timeout setting to "Never"?

    Thanks

  8. #8
    PowerPoster
    Join Date
    Jan 2008
    Posts
    9,151

    Re: How to prevent stand by/hibernation?

    Disabling/Enabling hibernation has no effect on the other settings. If hibernation is enabled but System hibernates is set to Never then the PC will not go into hibernation. If hibernation is disabled then even if System hibernates is set to a certain time it will not go into hibernation.

    As far as all computers support being awakened once in these power saving modes I don't know but I do know that my computer is at least 10 years old and it can be awakened.

    Why don't you just make a small app and see for yourself. Look in the forum for code on how to change the registry from your VB app. There is plenty around or even Google it


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  9. #9
    PowerPoster
    Join Date
    Feb 2006
    Posts
    11,418

    Re: How to prevent stand by/hibernation?

    Task Scheduler 2.0 provides for waking itself:
    Define routine tasks to run even when a machine is in standby or hibernate mode. Task Scheduler wakes the machine from Hibernation or Standby and then runs the task.
    This is quite different from fiddling with system configuration registry keys, which is more-than-borderline malware activity. These are administrative options, not something a legitimate application should ever be changing. Anti-malware suites may even trap on such a thing and kill the process and quarantine the executable.

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    159

    Re: How to prevent stand by/hibernation?

    Quote Originally Posted by jmsrickland View Post
    Disabling/Enabling hibernation has no effect on the other settings. If hibernation is enabled but System hibernates is set to Never then the PC will not go into hibernation. If hibernation is disabled then even if System hibernates is set to a certain time it will not go into hibernation.

    As far as all computers support being awakened once in these power saving modes I don't know but I do know that my computer is at least 10 years old and it can be awakened.

    Why don't you just make a small app and see for yourself. Look in the forum for code on how to change the registry from your VB app. There is plenty around or even Google it
    Thanks, but it's not just hibernation I want to disable, but Stand By also. And I don't really want to disable them, I just want to delay them until all scheduled tasks are run. Can stand by be disabled/postponed with registry settings as well?

    I had originally thought of just making the program use SendKeys and simulate hitting the control key every10 minutes or so, but if the user happens to be typing while the program simulates a press on the Ctrl key then it could do as if the user pressed Ctrl+[whatever key they were pressing at the time] which would have undesirable results.

    Is there a way of simulating user activity in a way that cannot possibly interfere with anything other than delaying power save modes?

    Thanks

  11. #11
    PowerPoster
    Join Date
    Feb 2006
    Posts
    11,418

    Re: How to prevent stand by/hibernation?

    Prior to modern versions of Windows the way to do this was for the user to configure the power options to have Sleep and Hibernate turned off. I'm not sure what the problem with that might be, since it is pretty normal for applications to list such things as prerequisites.

    You seem to be insisting on some kind of hack where none is needed.

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    159

    Re: How to prevent stand by/hibernation?

    Some users don't realize they need to disable Stand By or Hibernation and then think the software doesn't work and I would like it to detect if these are enabled and have a message such as "<software name> has detected your computer is set to enter Stand By or Hibernation after a period of inactivity. The software cannot run scheduled tasks while the computer is in these power saving modes, would you like them to be automatically disabled when there are scheduled tasks?"

    This would make it more user friendly without changing their settings without permission.

    Does anyone know the registry key for the stand by setting? If not I'll try to find it.

    Thanks

  13. #13
    PowerPoster
    Join Date
    Jan 2008
    Posts
    9,151

    Re: How to prevent stand by/hibernation?

    Start-->Run

    Type in:

    cmd.exe /k powercfg.exe /?

    This will display all the information on how to do what you need. Once you figure out what parameters you need to send to powercfg.exe you will need to set up a Shell("c:\windows\system32\powercfg.exe <----parameters----->") function call in your VB app.

    Here is an example of parameters:
    Code:
    /CHANGE scheme /standby-timeout-ac 0      disables Standby
    /CHANGE scheme /hibernate-timeout-ac 0    disable Hibernate
    scheme is one of the following:

    "Max Battery"
    "Minimal Power Management"
    "Always On"
    Presentation
    "Portable/Laptop"
    "Home/Office Desk"

    " marks are required if scheme contains spaces

    On my computer scheme is Home/Office Desk
    Last edited by jmsrickland; May 10th, 2012 at 12:05 AM.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.