I want to know on when was the last time the system was started.
Environment.TickCount will work but it is breaking after 48-49 days because of the limitation of int
public void BootTime(){
SelectQuery query = new SelectQuery("SELECT LastBootUpTime FROM Win32_OperatingSystem WHERE Primary='true'");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
foreach (ManagementObject mo in searcher.Get())
{
DateTime dtBootTime = ManagementDateTimeConverter.ToDateTime(mo.Properties["LastBootUpTime"].Value.ToString());
Console.WriteLine(dtBootTime.ToString());
}
}