Archive: Change Power configuration


Change Power configuration
  Has anyone figured out a way to change the 'Advanced' settings in the 'Power Options Properties' of a Windows XP machine from an installer?

Powercfg works for the 'Power Schemes', but not for anything in the 'Advanced' tab. I've googled and googled and have come up short.

As a workaround, I have the following in my script, but I don't like this method and I'd really prefer to make it automated if at all possible.


Section

ExecShell "" "$SYSDIR\Powercfg.cpl"
MessageBox MB_OK "Click on the 'Advanced' tab. In the 'Power Buttons' heading, \
change the option for 'When I close the lid of my portable computer:' to 'Do Nothing'. \
Then click 'Apply' and close the window. The installation will then continue."

>SectionEnd
>

The power settings are stored in the RegBinary value:

HKCU\Control Panel\PowerCfg\GlobalPowerPolicy\Policies
I don't know exactly what needs changed but you can do a before and after comparison easily enough.

Yeah, I've done this over and over. Changing here doesn't work.

I've used RegShot to see the differences and changed them, but testing shows that while the registry entries are indeed changed, the actual power configuration on the 'Advanced' tab is not. This seems to be a common theme all across the interwebz.

I was just hoping that someone here had figured out a way to do it from within NSIS.


Technically, you'd have to change the power policy - lots of System plugin interaction - nom. See:
edit: the link gets killed because it's a .info site - go figure :)
http://www.databaseforum[dot]info/30/648583.aspx

I'm not sure if there's a simpler API call that just lets windows pick up on the new registry settings - I would suspect those values are written as a result of policy changes, rather than used as a reference (except after a reboot, maybe).
The system itself sends WM_POWERBROADCAST PBT_POWERSETTINGCHANGE ... to applications to signal setting changes. I presume you've already googled those to death, though.


I found the APIs to use and have them working in AutoIt... I just need to convert them to NSIS.

I haven't abandoned you.. it's just more complicated than I thought.. ;)


Put them in an executable or DLL and run it. Simples!

Stu


It's only simple if you know how to program in a VC++ environment. It's on my todo list to learn though. ;)


I kept playing with it too, but no matter what resource I used I couldn't get it to work.

I'm using my workaround at the moment, but my goal is to make the installer unattended in the long run so I'm anxious to get it working.

I absolutely appreciate any work you put in to making this work, as I am sure does the rest of the internetz.


I got to thinking about this a bit. AutoIt can compile standalone executable from the scripts. Why not just create the exe and call it from NSIS?

If you have a working AutoIt script, can you post the script here?


isn't AutoIt rather UI-dependent? I.e. you tell it to "click this button, now click this one, now click in this field and 'type' this number", etc. Given the power scheme bits and pieces vary between Windows versions, that doesn't seem like a prudent path.