PwrTest 请求场景会在系统中运行的进程和服务发出电源请求时进行记录。
可以使用 PwrTest 请求方案来诊断计算机无法进入睡眠状态的原因或监视器保持运行的原因。
还可以将管理员工具 PowerCfg (powercfg.exe)用于此目的(powercfg.exe/requests)。 PowerCfg 包含在 Windows(Windows\System32 目录)中。 但是,Powercfg.exe 仅捕获运行该工具时处于活动状态的电源请求。 相比之下,PwrTest 请求方案会运行指定的时间,并在电源请求被创建和关闭时记录它们,因此在运行该工具时请求不需要处于活动状态。
语法
pwrtest /requests [/t:n] [/?]
/t:n
指定要运行的方案的总时间(以分钟为单位)( n 的默认值 为 30 分钟)。
示例
pwrtest /requests
pwrtest /requests /t:60
XML 日志文件输出
<PwrTestLog>
<SystemInformation>
</SystemInformation>
<PowerRequests>
<CreatePowerRequestEvent>
<Timestamp></TimeStamp>
<Caller></Caller>
<Context></Context>
<RequestObject></RequestObject>
<Type></Type>
<ProcessID></ProcessID>
<SessionID></SessionID>
<Legacy></Legacy>
<SystemAllowed></SystemAllowed>
<DisplayAllowed></DisplayAllowed>
<AwayModeAllowed></AwayModeAllowed>
<PerfBoostAllowed></PerfBoostAllowed>
<ExecutionRequiredAllowed></ExecutionRequiredAllowed>
<SystemCount></SystemCount>
<DisplayCount></DisplayCount>
<AwayModeCount></AwayModeCount>
<PerfBoostCount></PerfBoostCount>
<ExecutionRequiredCount></ExecutionRequiredCount>
</CreatePowerRequestEvent>
<ChangePowerRequestEvent>
<Timestamp></TimeStamp>
<Caller></Caller>
<RequestObject></RequestObject>
<SystemCount></SystemCount>
<DisplayCount></DisplayCount>
<AwayModeCount></AwayModeCount>
<PerfBoostCount></PerfBoostCount>
<ExecutionRequiredCount></ExecutionRequiredCount>
</ChangePowerRequestEvent>
<ClosePowerRequestEvent>
<Timestamp></TimeStamp>
<Caller></Caller>
<RequestObject></RequestObject>
</ClosePowerRequestEvent>
</PowerRequests>
</PwrTestLog>
下表描述了日志文件中显示的 XML 元素。
| 元素 | DESCRIPTION |
|---|---|
| <PowerRequests> | 包含所有不同的电源请求事件。 PwrTest 日志文件中只能有一个 <PowerRequests> 元素。 |
| <时间戳> | 任何给定事件的时间戳。 |
| <访客> | 请求者的名称。 |
| <上下文> | 设备实例路径(如果适用) |
| <RequestObject> | 用于事件的请求对象。 |
| <类型> | 调用者的数值类型。 0 = 驱动程序 1 = 进程 2 = 共享服务 |
| <ProcessID> | 调用方的进程 ID。 |
| <SessionID> | 如果是进程,则为调用者的会话 ID。 |
| <遗产> | 如果调用方使用了旧 版 SetThreadExecutionState 函数(Windows) 或 PoSetSystemState API 或较新的 PowerSetRequest 函数(Windows) 或 PoSetPowerRequest API,则报告 True 或 False。 |
| <SystemAllowed> | 报告是否允许此调用方使用系统请求。 |
| <DisplayAllowed> | 报告是否允许此调用方显示请求。 |
| <AwayModeAllowed> | 报告是否允许此调用方发出离开模式请求。 |
| <PerfBoostAllowed> | 报告此调用方是否允许性能提升请求。 |
| <ExecutionRequiredAllowed> | 报告是否允许此调用方执行相关请求。 |
| <SystemCount> | 此调用方的系统请求数。 |
| <DisplayCount> | 此调用方的显示请求次数。 |
| <AwayModeCount> | 此调用方的客场模式请求数。 |
| <PerfBoostCount> | 此调用方的性能提升请求数。 |
| <ExecutionRequiredCount> | 此调用方所需执行的请求次数。 |
| <创建电源请求事件> | 调用方已创建新请求。 |
| <ChangePowerRequestEvent> | 调用方已更改请求计数。 |
| <ClosePowerRequestEvent> | 调用方已关闭请求。 |