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?
Asked
Active
Viewed 2,298 times
2 Answers
3
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. – Morbo Aug 01 '11 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. – Morbo Aug 02 '11 at 00:12
-
That mean no way or API to get windows service uptime directely i must find its process then find starttime – ali Aug 02 '11 at 08:11
1
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.

cgon
- 1,955
- 2
- 23
- 37