Hi ericrichner,
I have had the similar goal for a while:
switching between:
"when I close the lid - Do nothing"
"when I close the Lid - Standby"
Because you ask in your post for "a program (or the code for it)", I
will assume that you can handle exporting a registry key and
creating/editing a batch file. And that you can adapt my method to
include your preference for Hibernate. Let me know if I am unclear on
any steps.
My Steps:
Open the "Power Options Properties" (Start\Run\powercfg.cpl)
Go to the "Advanced" tab.
Set "When I close the lid of my portable computer" to "Do Nothing"
Click Apply
Using Regedit, export the
[HKEY_CURRENT_USER\Control Panel\PowerCfg\GlobalPowerPolicy]
Key into "DoNothingMode.reg":
Go back to "Power Options Properties" dialogue
Set "When I close the lid of my portable computer" to "Stand by"
Click Apply
Using Regedit, export the same key into "StandByMode.reg"
Repeat for "Hibernate"
In the end you should have a couple of .reg files.
DoNothingMode.reg
StandbyMode.reg
HibernateMode.reg
All you need now is to create a batch file for each of those .reg files as follows:
DoNothingMode.bat:
regedit /s "DoNothingMode.reg"
rundll32.exe powrprof.dll,LoadCurrentPwrScheme
StandbyMode.bat:
regedit /s "StandbyMode.reg"
rundll32.exe powrprof.dll,LoadCurrentPwrScheme
Hibernate.bat:
You can probably take it from here ;-)
So, if you compare your three .reg files, there is very little
difference, maybe 2 or 3 bytes, I haven't investigated too deeply into
the structure of this registry key.
Just merging the registry file isn't enough though
The rundll32 step in the batch file turn out to be the magic trick
that activates the changed that you make to the registry.
So, hope it works for you, also as this is my first comment of Google
Answers, I hope my formatting doesn't go crappy.
Cheers,
Ben. |