How do I read individual PowerCfg settings?

耗尽温柔 提交于 2020-01-15 12:15:07

问题


If I run this command:

powercfg -SETACTIVE 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c

...I can subsequently run this command:

powercfg -GETACTIVESCHEME

...and it will tell me what I did. (It will output 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c.)

Similarly, if I run this command:

powercfg -change -monitor-timeout-dc 0

I want to know how I can query that. Is there some powercfg flag where I can read the current value of monitor-timeout-dc, and other settings like that?


回答1:


This returns the monitor timeout (in seconds) to turn off. Note that i'm skiping 16 lines for DC timeout, if you want AC timeout then skip 15 lines.

@echo off
setlocal enabledelayedexpansion

set SCHEME=8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
set VIDEO_GUID=7516b95f-f776-4464-8c53-06167f40cc99

for /f "skip=16 tokens=1*" %%a in ('powercfg -Q !SCHEME! !VIDEO_GUID!') do (
for /f "tokens=2 delims=:" %%c in ('echo/%%a%%b') do (
set /a "timeout=%%c"&goto break))
:break
echo/%timeout%
pause>nul

You can query any configuration. For a list of schemes use powercfg -list, for a list of guids use powercfg -aliases



来源:https://stackoverflow.com/questions/28049663/how-do-i-read-individual-powercfg-settings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!