问题
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?
回答1:
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.
回答2:
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
回答3:
powercfg /q will list out all the configuration parameters, in addition, for each guid (except the plan) there is an alias.
e.g. powercfg /setacvalueindex 381b4222-f694-41f0-9685-ff5bb260df2e SUB_SLEEP UNATTENDSLEEP 1800
here is an abbreviated output of the /q Subgroup GUID: 238c9fa8-0aad-41ed-83f4-97be242c8f20 (Sleep) GUID Alias: SUB_SLEEP Power Setting GUID: 7bc4a2f9-d8fc-4469-b07b-33eb785aaca0 (System unattended sleep timeout) GUID Alias: UNATTENDSLEEP
来源:https://stackoverflow.com/questions/10723339/changing-power-scheme-settings-through-registry-instead-of-control-panel-in-wind