有什么方法可以查看上次重启是如何执行的?
Any way to see how last reboot was executed?
我正在尝试使用 ManagementObjectSearcher 从我的系统中获取一些信息。我设法使用此代码获得了上次重启时间:
private String getLastRebootTime()
{
DateTime bootTime = new DateTime();
ManagementObjectSearcher mos1 = new System.Management.ManagementObjectSearcher(@"\.\root\CIMV2", "SELECT LastBootUpTime FROM Win32_OperatingSystem WHERE Primary='true'");
foreach (ManagementObject mo in mos1.Get())
{
bootTime =
ManagementDateTimeConverter.ToDateTime(mo.Properties["LastBootUpTime"].Value.ToString());
}
return bootTime.ToString();
}
我现在想知道是否可以获得有关上次重启执行方式的信息。例如,如果是手动重启或脏重启。
检查 this answer 和关于如何搜索日志的评论。他们正在寻找最后一个时间戳,但评论似乎也提供了您需要的解决方案。
我想你在找:
Log = "System"
Source = "EventLog"
Filter EventLogEntry for EventID == 6008
我正在尝试使用 ManagementObjectSearcher 从我的系统中获取一些信息。我设法使用此代码获得了上次重启时间:
private String getLastRebootTime()
{
DateTime bootTime = new DateTime();
ManagementObjectSearcher mos1 = new System.Management.ManagementObjectSearcher(@"\.\root\CIMV2", "SELECT LastBootUpTime FROM Win32_OperatingSystem WHERE Primary='true'");
foreach (ManagementObject mo in mos1.Get())
{
bootTime =
ManagementDateTimeConverter.ToDateTime(mo.Properties["LastBootUpTime"].Value.ToString());
}
return bootTime.ToString();
}
我现在想知道是否可以获得有关上次重启执行方式的信息。例如,如果是手动重启或脏重启。
检查 this answer 和关于如何搜索日志的评论。他们正在寻找最后一个时间戳,但评论似乎也提供了您需要的解决方案。
我想你在找:
Log = "System"
Source = "EventLog"
Filter EventLogEntry for EventID == 6008