ePe*_*man 16 windows power windows-7 power-supply
在 Windows (7/8/10) 上,无论如何要找出计算机是否在给定时间运行?(例如,昨晚 10 点,如果计算机正在运行或已关闭)谢谢
Mon*_*eth 21
您可以使用Windows 事件查看器来执行此操作。
在 Windows 7 中启动事件查看器:
在 Windows 8 和 10 中,您可以使用Windows Key+ X+V快捷方式运行事件查看器。您也可以通过“运行”菜单打开它。即,按Windows Key+R打开“运行”对话框,然后键入eventvwr并单击“确定”。
打开事件查看器后,请按照下列步骤操作:
请注意,事件查看器可能需要一些时间才能显示过滤后的日志。
总之:
事件 ID 6005表示“事件日志服务已启动”(即启动时间)。
事件 ID 6006表示“事件日志服务已停止”(即关闭时间)。
如果需要,您还可以将事件 ID 6013 添加到您的过滤器中——这会显示系统启动后的正常运行时间。
最后,如果这是您想要定期检查的内容,您可以创建一个自定义视图来显示此过滤日志。自定义视图位于 Windows 事件查看器左窗格的左上角。通过在那里添加它,您可以选择在想要查看日志时选择它。
请注意,当计算机进入睡眠状态时,服务不会停止,但Kernel-Power事件源会提及所有电源状态转换。要从命令行查询事件日志,可以使用 PowerShell!
Get-WinEvent -LogName System | ? {$_.ProviderName -eq 'Microsoft-Windows-Kernel-Power'}
Run Code Online (Sandbox Code Playgroud)
在我的笔记本电脑上,这会生成如下列表:
TimeCreated Id LevelDisplayName Message
----------- -- ---------------- -------
10/21/2016 1:20:43 PM 130 Information Firmware S3 times. SuspendStart: 31954205, SuspendEnd: 31954215
10/21/2016 1:20:43 PM 131 Information Firmware S3 times. ResumeCount: 11, FullResume: 498, AverageResu...
10/21/2016 1:16:54 PM 107 Information The system has resumed from sleep.
10/21/2016 1:16:53 PM 42 Information The system is entering sleep....
10/21/2016 1:06:05 PM 130 Information Firmware S3 times. SuspendStart: 31305142, SuspendEnd: 31305152
10/21/2016 1:06:05 PM 131 Information Firmware S3 times. ResumeCount: 10, FullResume: 498, AverageResu...
10/21/2016 12:29:30 PM 107 Information The system has resumed from sleep.
10/21/2016 12:29:29 PM 42 Information The system is entering sleep....
Run Code Online (Sandbox Code Playgroud)
奇怪的是,有时事件 107 上的时间是不正确的(这台笔记本电脑在恢复时会短暂地忘记时间),但下一个“固件 S3 时间”事件却是正确的。
当然,如果计算机意外关机,您不会在关机的确切时间收到事件 - 下一次Kernel-Power将是系统意识到断电时。因此,另一种方法是查找在相关时间之前记录的任何类型的最新事件。
Get-WinEvent -LogName Application | ? {$_.TimeCreated -le '10/19/2016 12:45 PM'} | select -First 1
Run Code Online (Sandbox Code Playgroud)
您将替换10/19/2016 12:45 PM为您感兴趣的时间。我为此查询选择了应用程序日志,因为它通常非常活跃。如果TimeCreated生成的事件的时间比您提供的时间早一个多小时,则可能是计算机没有完全运行。