Windows 8 报告错误的正常运行时间(可能是混合启动的总正常运行时间)

Aks*_*tal 11 uptime windows-8 hybrid-boot

错误的正常运行时间

图中显示的正常运行时间为 6 天 1 小时 34 分 22 秒。大约 7 分钟前,我打开了这台笔记本电脑。

我实际上认为,Windows 8 报告处于混合启动模式时的总运行时间。我如何获得真正的上线时间?另外,为什么 Windows 会这样报告??

有没有办法以 GUI 方式(对于我的 n00b 朋友)获得实际运行时间?


更新:我禁用了混合启动并重新启动。它现在可以得到正确的正常运行时间。此外,完全关闭shutdown /s /t 0也可以。

更多的解释,我的问题是,即使启用了混合启动,如何获得实际的正常运行时间(从我们启动系统开始的时间)?可能有库存 Windows,无需任何外部程序,但不是必需的。


对此有什么解释吗?

asm*_*m00 6

您想获得一个开箱即用的解决方案来了解自上次混合关机/快速启动以来您的机器的正常运行时间,对吗?

您可以使用 PowerShell 从 EventLog 获取此信息(由@allquixotic 提供),如下所示:

PS c:\> Write-Host $("{0:c}" -f ((Get-Date)- (Get-EventLog -LogName system -Source "Microsoft-Windows-Power-Troubleshooter" -Newest 1).TimeGenerated))
Run Code Online (Sandbox Code Playgroud)

要将 powershell 命令嵌入到 Windows shell 脚本中,您可以改为执行以下操作:

c:\> powershell.exe -nologo -command Write-Host $('Time since last ''Fast Startup'': {0:c}' -f ((Get-Date)- (Get-EventLog -LogName system -Source \"Microsoft-Windows-Power-Troubleshooter\" -Newest 1).TimeGenerated))
Run Code Online (Sandbox Code Playgroud)

但是,要使其开箱即用,您可以将其设置为这样的永久环境变量:

c:\> setx HardwareUptime "powershell.exe -nologo -command Write-Host $('Uptime since last ''Fast Startup'': {0:c}' -f ((Get-Date)- (Get-EventLog -LogName system -Source 'Microsoft-Windows-Power-Troubleshooter' -Newest 1).TimeGenerated))"
Run Code Online (Sandbox Code Playgroud)

因此,您可以通过打开一个cmd窗口并执行以下操作来使其工作:

c:\> %HardwareUpTime%
Run Code Online (Sandbox Code Playgroud)

更新:

我今天刚刚发现,在事件日志中使用上述条目也会考虑“睡眠”或挂起模式,因此%HardwareUpTime%如果您让它这样做,运行会告诉您自 PC 从睡眠状态恢复以来经过的时间。

因此,这里是:

setx HardwareUptime "powershell.exe -nologo -command Write-Host $('Uptime since hardware boot: {0:c}' -f ((Get-Date)- (Get-EventLog -LogName system -InstanceId 27 -Newest 1).TimeGenerated)); Write-Host $('Uptime since system resumed: {0:c}' -f ((Get-Date)- (Get-EventLog -LogName system -Source 'Microsoft-Windows-Power-Troubleshooter' -Newest 1).TimeGenerated));"
Run Code Online (Sandbox Code Playgroud)

我对命令进行了一些修改,使其更加明确,并为您提供了两条信息:

  • 自 Windows 启动后经过的时间(混合关机、完全关机或简单重启或休眠后)。

  • 自 Windows 恢复执行后经过的时间(从睡眠模式返回后)。

注意:如果系统在这之间没有休眠,则两个时间将相同。