Getting the Windows uptime

1.1k Views Asked by At

How can I get the uptime day by day in windows 7 for the last month?

the system sometime hibernate in the middle of day for few hours. or may be shuted-down.

My expected output is like the following:

Start Time |   UpTime  |
2013/12/1  |  28:31:20 |
2013/12/3  |  42:29:51 |
2013/12/7  | 128:22:17 |

UPDATE 2013-12-15

I found this article but I can't find any event with 6005, 6006, 6008 or 6009 in my event viewer under windows 7


UPDATE 2013-12-19 I'm looking for a C# code that helps me to read events from the windows eventlog to calculate the uptime in a specific period of time. Quering the WMI results only to get the uptime of the current session.

2

There are 2 best solutions below

0
On

See this answer to a similar question that shows a way that uses PowerShell and WMI. You can transfer this to .NET and run a similar WMI query. For a tutorial on WMI and C# see this link.
There are several other options that are listed in the other answers to the aforementioned question.

1
On

You can't get such information without additional friction. But you can calculate these time periods from Windows Event Log, based on Logon\Logoff events.

You can get full list of logon\logof events from Eventopedia

Check your system log for 528 and 538 events.