Reputation: 23833
All, I want to find out the dates that the Windows OS was not started. Is there a way to do this in C# using .NET4.5+?
Following searches on this I have found nothing and am not sure where to start with this. If this is not possible via C# is there a way to do this via the OS?
Thanks for your time.
Upvotes: 0
Views: 95
Reputation: 3752
One way to do it would be to check the event logs. Here are some of the relevant eventIDs:
EventID Source Description
12 Kernel General Operating System Start
13 Kernel General Operating System Shutdown
1 Power-Troubleshooter Operating System Woke up from Sleep
42 Kernel-Power Operating System going to Hibernate/Sleep
By looking for eventid 12, you will be able to find out the dates when the OS was started.
More info at http://unlimit.in/calculating-uptimes-in-windows.html
Upvotes: 1