2

I am trying to write a script to toggle the lid action between sleep/do nothing by using powercfg.exe and the relevant GUID.

powercfg -SETACVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 0
powercfg -SETDCVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 0

To do nothing, and

powercfg -SETACVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 1
powercfg -SETDCVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 1

To sleep.

Whether I enter them manually or as part of a .bat file the result is the same. I can see the settings change in ControlPanel>PowerOptions>ChangeWhatClosingTheLidDoes but the behavior doesn't change.

If you look at this short video you will see what I mean, the setting changes, but not the behavior;

https://www.youtube.com/watch?v=N1yjiTMgnzk&feature=youtu.be

In the video I am running toggle script I am trying to make, but the result is the same if I manually enter the commands.

I'm on Win7 x64.

Any help or suggestions would be greatly appreciated, thanks for reading.

user3133275
  • 41
  • 1
  • 8
  • Got it, http://stackoverflow.com/questions/23602077/cant-get-powercfg-setacvalueindex-to-work-with-changing-lid-closing-actions-s?rq=1 I found it in the related column, I did search! – user3133275 May 30 '14 at 17:17
  • hey, that link has been removed @user3133275 and so had the video you posted. I'm running into the same problem, could you share what the solution was for you? – Jay S. Dec 16 '14 at 00:45
  • @JayS. The key step that you're probably missing (as per [Alex's answer](https://stackoverflow.com/a/29157656/224704)) is to reapply the active scheme using `powercfg -SetActive`. If that works for you, I suggest you up-vote his answer. – Disillusioned Sep 21 '17 at 06:50

1 Answers1

3

You have to activate the energy plan after you set the changes. Execute the following command:

powercfg -setactive $GUID

where $GUID is the guid of the changed energy plan (check it with powercfg -l). So for example the upper script for suspending when the lid is closed would have to be:

    powercfg -SETACVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 1
    powercfg -SETDCVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 1
    powercfg -SETACTIVE 381b4222-f694-41f0-9685-ff5bb260df2e

Found the solution in this forum, see the edit of the 9th post: http://www.autoitscript.com/forum/topic/85107-set-on-lid-close-power-option/?p=1173900

Alex
  • 31
  • 2