0

So I'm trying to get a bat file together with power settings that I want to apply. But I'm running into an issue. For some reason, the power button and lid close actions wont change. Here is the relevant code from the bat:

set pf=powercfg
set av=setacvalueindex
set pm=8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c

rem lid close
%pf% /%av% %pm%    4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 003
rem power button
%pf% /%av% %pm%    4f971e89-eebd-4455-a8de-9e59040e7347 7648efa3-dd9c-4e3e-b566-50f929386280 003
rem sleep button                                                        
%pf% /%av% %pm%    4f971e89-eebd-4455-a8de-9e59040e7347 96996bc0-ad50-47ec-923b-6f41874dd9eb 003

%pf% -setactive %pm%
pause    

And a bit of the relevant output from powercfg -query:

Subgroup GUID: 4f971e89-eebd-4455-a8de-9e59040e7347  (Power buttons and lid)
 GUID Alias: SUB_BUTTONS
  Power Setting GUID: 5ca83367-6e45-459f-a27b-476b1d01c936  (Lid close action)
    GUID Alias: LIDACTION
    Possible Setting Index: 000
    Possible Setting Friendly Name: Do nothing
    Possible Setting Index: 001
    Possible Setting Friendly Name: Sleep
    Possible Setting Index: 002
    Possible Setting Friendly Name: Hibernate
    Possible Setting Index: 003
    Possible Setting Friendly Name: Shut down
  Current AC Power Setting Index: 0x00000003
  Current DC Power Setting Index: 0x00000003   

As you can see, the lid close action is properly set now, as are the other two. However, when I go into control panel, it still says Sleep.

Anyone know what's going on?

Ken White
  • 123,280
  • 14
  • 225
  • 444
lobstrosity
  • 37
  • 1
  • 5
  • Have you rebooted. Many registry keys are ONLY read on Startup or Logon. – BambiLongGone Dec 12 '14 at 01:48
  • @BambiLongGone I have not, but I will give that a shot now. However, I was under the impression that -setactive would remove the need to restart. – lobstrosity Dec 12 '14 at 01:57
  • It would depend if there was an API call to do that. Most explorer settings, except folder settings, are read on startup and written of shutdown (only if you shutdown cleanly). The Kernel is similar. You need to use API calls to affect memory copies of registry data or reboot/restart the app to reread changed values. – BambiLongGone Dec 12 '14 at 02:01
  • @BambiLongGone Interesting! Just to let ya know, I tried it again. these settings change instantly: scheme plan, brightness settings, turn off the display, and put the computer to sleep. The only two that didn't change were the close lid and power button settings. Upon restart they remain unchanged, even though -query shows them as being set to 003. – lobstrosity Dec 12 '14 at 02:22

1 Answers1

0

This works for me, for the lid action, without reboot:

powercfg -setacvalueindex SCHEME_BALANCED SUB_BUTTONS LIDACTION 003
pstraton
  • 1,080
  • 14
  • 9