查询 Windows 7 上的当前电源配置设置

查询 Windows 7 上的当前电源配置设置

Powercfg 允许使用来设置某些设置,例如monitor-timeout-ac和。是否可以查询这些设置的当前值?我查看了帮助文本,但没有找到通过命令的方法。也许还有其他命令可以提供当前状态?standby-timeout-dcpowercfg -change <setting> <value>powercfg

答案1

要查询有关您提到的特定设置的特定部分,请执行以下操作:

  • powercfg -list获取当前电源计划 GUID 列表。记下/复制您要查询的计划的 GUID。
  • powercfg -aliases获取计划子部分的 GUID 列表。注意/复制“SUB_SLEEP”和“SUB_VIDEO”的 GUID。
  • powercfg -query <GUID of power plan> <GUID of sub-section>

“SUB-SLEEP”子部分的示例输出:

C:\Windows\system32>powercfg -query 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c 238c9fa8-0aad-41ed-83f4-97be242c8f20

Power Scheme GUID: 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c  (High performance)
  Subgroup GUID: 238c9fa8-0aad-41ed-83f4-97be242c8f20  (Sleep)
    Power Setting GUID: 29f6c1db-86da-48c5-9fdb-f2b67b1f44da  (Sleep after)
      Minimum Possible Setting: 0x00000000
      Maximum Possible Setting: 0xffffffff
      Possible Settings increment: 0x00000001
      Possible Settings units: Seconds
    Current AC Power Setting Index: 0x00000000
    Current DC Power Setting Index: 0x00000000

    Power Setting GUID: 94ac6d29-73ce-41a6-809f-6363ba21b47e  (Allow hybrid sleep)
      Possible Setting Index: 000
      Possible Setting Friendly Name: Off
      Possible Setting Index: 001
      Possible Setting Friendly Name: On
    Current AC Power Setting Index: 0x00000001
    Current DC Power Setting Index: 0x00000001

    Power Setting GUID: 9d7815a6-7ee4-497e-8888-515a05f02364  (Hibernate after)
      Minimum Possible Setting: 0x00000000
      Maximum Possible Setting: 0xffffffff
      Possible Settings increment: 0x00000001
      Possible Settings units: Seconds
    Current AC Power Setting Index: 0x00000000
    Current DC Power Setting Index: 0x00000000

    Power Setting GUID: bd3b718a-0680-4d9d-8ab2-e1d2b4ac806d  (Allow wake timers)
      Possible Setting Index: 000
      Possible Setting Friendly Name: Disable
      Possible Setting Index: 001
      Possible Setting Friendly Name: Enable
    Current AC Power Setting Index: 0x00000001
    Current DC Power Setting Index: 0x00000001

“SUB_VIDEO”部分的示例:

C:\Windows\system32>powercfg -query 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c 7516b95
f-f776-4464-8c53-06167f40cc99

Power Scheme GUID: 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c  (High performance)
  Subgroup GUID: 7516b95f-f776-4464-8c53-06167f40cc99  (Display)
    Power Setting GUID: 17aaa29b-8b43-4b94-aafe-35f64daaf1ee  (Dim display after)
      Minimum Possible Setting: 0x00000000
      Maximum Possible Setting: 0xffffffff
      Possible Settings increment: 0x00000001
      Possible Settings units: Seconds
    Current AC Power Setting Index: 0x00000258
    Current DC Power Setting Index: 0x0000012c

    Power Setting GUID: 3c0bc021-c8a8-4e07-a973-6b14cbcb2b7e  (Turn off display after)
      Minimum Possible Setting: 0x00000000
      Maximum Possible Setting: 0xffffffff
      Possible Settings increment: 0x00000001
      Possible Settings units: Seconds
    Current AC Power Setting Index: 0x00000384
    Current DC Power Setting Index: 0x00000258

    Power Setting GUID: aded5e82-b909-4619-9949-f5d71dac0bcb  (Display brightness)
      Minimum Possible Setting: 0x00000000
      Maximum Possible Setting: 0x00000064
      Possible Settings increment: 0x00000001
      Possible Settings units: %
    Current AC Power Setting Index: 0x00000064
    Current DC Power Setting Index: 0x00000064

    Power Setting GUID: f1fbfde2-a960-4165-9f88-50667911ce96  (Dimmed display brightness)
      Minimum Possible Setting: 0x00000000
      Maximum Possible Setting: 0x00000064
      Possible Settings increment: 0x00000001
      Possible Settings units: %
    Current AC Power Setting Index: 0x0000001e
    Current DC Power Setting Index: 0x0000001e

答案2

我没有足够的声誉来评论@randy 的优秀答案,但我想我会在最后为那些只想要十进制格式的时间的人添加一点点:

#Show Current Settings
$sleeptime = [uint32]"$sleepSettingTrimmed"
$hibtime = [uint32]"$hibernateSettingTrimmed"

if($sleepSettingTrimmed -eq "0x00000000")
{
Write-Host "Sleep is currently disabled on AC."
}
else
{
write-host "Time to Sleep on AC is currently $sleeptime seconds."
}

if($hibernateSettingTrimmed -eq "0x00000000")
{
Write-Host "Hibernation is currently disabled on AC."
}
else
{
write-host "Time to Hibernate on AC is currently $hibtime seconds."
}

答案3

是的。令人惊讶的是,它使用以下设置:

powercfg -query

以下是该命令的摘录powercfg -? |more

POWERCFG <command line options>
Description:
  This command line tool enables users to control the power settings
  on a system.

Parameter List:
  -LIST, -L   Lists all power schemes in the current user's environment.

          Usage: POWERCFG -LIST

  -QUERY, -Q  Displays the contents of the specified power scheme.

          Usage: POWERCFG -QUERY <SCHEME_GUID> <SUB_GUID>

          <SCHEME_GUID>  (optional) Specifies the GUID of the power scheme
                         to display, can be obtained by using powercfg -l.
          <SUB_GUID>     (optional) Specifies the GUID of the subgroup
                         to display.  Requires a SCHEME_GUID to be provided.

          If neither SCHEME_GUID or SUB_GUID are provided, the settings
          of the current user's active power scheme are displayed.
          If SUB_GUID is not specified, all settings in the specified
          power scheme are displayed.

希望这可以帮助。 :)

答案4

# get current power sleep time setting
# I know of no other way to return the single number of the sleep time
# (powershell)
# run script with "powershell -file" to get errorlevel set right

# (Balanced plan) (Sleep section)
# can't do (Sleep after subsection guid) too?
$result = powercfg -query 381b4222-f694-41f0-9685-ff5bb260df2e 238c9fa8-0aad-41ed-83f4-97be242c8f20

# line 8, 7th word, in hex, cast to decimal
[int64]$sleeptime = ($result[7] -split ("\s+"))[6]

# return sleep time in minutes in errorlevel
exit $sleeptime/60

相关内容