1

I don't want my default sleep action to be hybrid sleep, but occasionally I want to use hybrid sleep.

How do I tell Windows, "go into hybrid sleep"?


Note: I am not asking for the "sleep" option (standby) to be replaced with the hybrid sleep action. I need both to be available.

12
  • You mean you want your default to be hibernation? Also, take a look at this question: superuser.com/questions/189008/… May 9, 2011 at 16:24
  • 1
    @studiohack: Hibernation is not hybrid sleep. :( I want my standby and hibernate option to both be there and occasionally choose hybrid sleep, not the other way around... is this really a dup?
    – user541686
    May 9, 2011 at 16:34
  • The question still reads like a duplicate...You're asking to have both sleep and hibernate options on the Start menu, correct?
    – studiohack
    May 9, 2011 at 16:42
  • @studiohack: Yes, I'm asking for both sleep and hibernate to be there, and I want to somehow choose a third "hybrid sleep" option if I need to. I do not want to change the meaning of "sleep" to mean "hybrid sleep", which is the only mechanism I can find that's allowed in Windows.
    – user541686
    May 9, 2011 at 16:43
  • @Downvoter: Care to comment?
    – user541686
    May 9, 2011 at 16:59

2 Answers 2

0

I ended up making a hacky program that does this by temporarily changing the settings, but this really isn't what I was looking for... if someone comes up with a better solution, do post it. Otherwise, in case anybody finds this helpful, here's the code:

#include <tchar.h>
#include <Windows.h>
#include <PowrProf.h>

extern "C"
//int  _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
int _tmain(int, LPTSTR[])
{
    ULONG error = 1;
    HANDLE hSem = CreateSemaphore(NULL, 1, 1, TEXT("Global\\HybridSleep.{A88FD0FD-4C24-23c0-88F6-B51A145FB444}"));
    if (hSem != NULL && GetLastError() != ERROR_ALREADY_EXISTS)
    {
        GUID *guid,
             allowHybridSleepGuid = { 0x94ac6d29, 0x73ce, 0x41a6, 0x80, 0x9f, 0x63, 0x63, 0xba, 0x21, 0xb4, 0x7e },
             sleepSubgroupGuid    = { 0x238C9FA8, 0x0AAD, 0x41ED, 0x83, 0xF4, 0x97, 0xBE, 0x24, 0x2C, 0x8F, 0x20 };
        SYSTEM_POWER_STATUS sps;
        if (GetSystemPowerStatus(&sps))
        {
            error = PowerGetActiveScheme(NULL, &guid);
            if (error == ERROR_SUCCESS)
            {
                __try
                {
                    ULONG index;
                    error = (sps.ACLineStatus ? PowerReadACValueIndex : PowerReadDCValueIndex)(NULL, guid, &sleepSubgroupGuid, &allowHybridSleepGuid, &index);
                    if (error == ERROR_SUCCESS && index <= 1)
                    {
                        __try
                        {
                            ULONG newIndex = 1 - index; //Opposite old value
                            error = (sps.ACLineStatus ? PowerWriteACValueIndex : PowerWriteDCValueIndex)(NULL, guid, &sleepSubgroupGuid, &allowHybridSleepGuid, newIndex);
                            if (error == ERROR_SUCCESS)
                            {
                                PowerSetActiveScheme(NULL, guid);
                                SetSuspendState(FALSE, FALSE, FALSE);
                            }
                        }
                        __finally
                        {
                            if ((sps.ACLineStatus ? PowerWriteACValueIndex : PowerWriteDCValueIndex)(NULL, guid, &sleepSubgroupGuid, &allowHybridSleepGuid, index) == ERROR_SUCCESS)
                            { PowerSetActiveScheme(NULL, guid); }
                        }
                    }
                }
                __finally { LocalFree(guid); }
            }
        }
    }
    return error;
}

It performs the opposite of the current Hybrid Sleep setting.

2
  • There has got to be an easier way to do this. I'm thinking a few lines in a batch file. Still "hacky" maybe, but probably a bit more trim. Trick is to find where the setting is stored.
    – Iszi
    May 19, 2011 at 4:30
  • @lszi: You indeed can do this with powercfg, but the trouble is the recovery: if for any reason you can't boot back, the setting will be changed permanently. I've found that if I modify my source code a bit, though, I can make it revert the setting before going into suspension, so that it always works. :)
    – user541686
    May 19, 2011 at 4:44
-1

In the control panel, you have the option to create your own power plan. You might be able to change the settings to your liking through that. You also might find more info here: http://windows.microsoft.com/en-us/windows7/Sleep-and-hibernation-frequently-asked-questions

1
  • How does creating my own plan help? There's still only two options I can seen in the start menu -- one hibernate, one sleep (standby). No hybrid sleep.
    – user541686
    May 9, 2011 at 16:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .