Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing Power Scheme settings through Registry instead of Control Panel in Windows 7

I'd like to change the settings of a power scheme (say, go to sleep after 45 minutes instead of 30) through the registry, rather than the control panel, in Windows 7. I'd also like to turn hot keys off the same way.

Any suggestions how I do it?

like image 378
ori Avatar asked Dec 01 '22 06:12

ori


2 Answers

I know this is an old question, but in case anyone has it again in the future, here's an example of code I got to work when I hit a similar issue.

Mind, I agree with the previous assessment of using and abstracted API, but in case this helps anyone:

::Set the 'Power Management' to Balanced
powercfg -SETACTIVE 381b4222-f694-41f0-9685-ff5bb260df2e

::Set the unplugged settings to 'Never'
powercfg.exe -change -monitor-timeout-dc 0
powercfg.exe -change -standby-timeout-dc 0
powercfg.exe -change -hibernate-timeout-dc 0

::Set the plugged in settings to 'Never'
powercfg.exe -change -monitor-timeout-ac 0
powercfg.exe -change -standby-timeout-ac 0
powercfg.exe -change -hibernate-timeout-ac 0

::Set the 'Dim Timeout' to Never
powercfg -SETDCVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 7516b95f-f776-4464-8c53-06167f40cc99 17aaa29b-8b43-4b94-aafe-35f64daaf1ee 0
powercfg -SETACVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 7516b95f-f776-4464-8c53-06167f40cc99 17aaa29b-8b43-4b94-aafe-35f64daaf1ee 0

Source of Reference: http://ss64.com/nt/powercfg.html

like image 138
CaptainKeyboarder Avatar answered Dec 09 '22 12:12

CaptainKeyboarder


I suspect this would be non-trivial due to the complexity of the power management architecture (schemes etc) & its always better to go through an abstracted API rather than fiddling with the underlying configuration data.

If you dont want to use the API there is the powercfg command line tool.

like image 21
Alex K. Avatar answered Dec 09 '22 12:12

Alex K.