When I have my laptop (Windows 10) plugged into my monitor, I like to keep the lid closed. I can do this by changing the settings circled in the snapshot at the bottom of this Q. When not plugged into the monitor, I prefer that the computer sleeps when the lid is closed.
Is there an easy way to change these settings through a batch script? It doesn't have to be a toggle; could have one script to change to "Do Nothing" and one to change to "Sleep".
Here's an untested example script for you to try:
@"%__AppDir__%powercfg.exe" -SetDCValueIndex Scheme_Current 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 1
@"%__AppDir__%powercfg.exe" -SetACValueIndex Scheme_Current 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 0
@"%__AppDir__%powercfg.exe" -SetActive Scheme_Current
The first command sets the current
power configuration When I close the lid
and On battery
to Sleep
. The second line sets the current
power configuration When I close the lid
and Plugged in
to Do nothing
. The third line activates the new settings.
[Edit /]
Based upon your comment regarding the GUID's, I have decided to add the below answer, which uses their aliases instead. You can find out those aliases along with their respective GUID's by entering "%__AppDir__%powercfg.exe" /Aliases
at the Command Prompt.
@"%__AppDir__%powercfg.exe" -SetDCValueIndex Scheme_Current Sub_Buttons LidAction 1
@"%__AppDir__%powercfg.exe" -SetACValueIndex Scheme_Current Sub_Buttons LidAction 0
@"%__AppDir__%powercfg.exe" -SetActive Scheme_Current