Is there is a way to get the start time of a windows service by code in C#? Is there is a way to get the number of re-starts of the windows service in last 72 hours?
2 Answers
This for the first question.
As for the second question, I think you would need to look at the Windows events to find how many time it started, unless you can change the code to log it somewhere.
-
That link gets you the start time of a particular process, not necessarily the OS. The "System Idle" and "System" processes have no start time that I can see in Process Explorer. The oldest process with a start time is "csrss.exe". Also be aware that with PCs that go into standby/hibernate if you get the original boot time it does not follow that the PC has been up for the whole time since then.– MorboCommented Aug 1, 2011 at 19:30
-
For some reason the word "the" in the title had me convinced the question was about the OS boot. Sorry for the confusion.– MorboCommented Aug 2, 2011 at 0:12
-
That mean no way or API to get windows service uptime directely i must find its process then find starttime– aliCommented Aug 2, 2011 at 8:11
You can try to capture it from the Event Log. As far as I know when a service starts it hooks an entry to the event log.