I am trying to get some information out of my system with the ManagementObjectSearcher. I managed to get my last reboot time with this code:
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();
}
I now want to know if it is possible to get info about how the last reboot was executed. For example if it was a manual reboot or a dirty reboot.