Is it possible to get the number of times a server gets restarted in a period of time using c#?
I have seen this post which is getting windows last shutdown time Get the date-time of last windows shutdown event using .NET
Any suggestion?
Is it possible to get the number of times a server gets restarted in a period of time using c#?
I have seen this post which is getting windows last shutdown time Get the date-time of last windows shutdown event using .NET
Any suggestion?
You could create a windows service and log the startup event. That way you will know how many times the service has started (and been shut down).
Have you considered reading from the server's event log?
The 'USER32' system event source records shutdowns.
From what I've read it seem that you should be able to read a remote machine's event log programmatically as well (See How to manage event logs using Visual C# .NET or Visual C# 2005)
EDIT
The following console app will work on querying the even log on a remote machine for the USER32 Type.
All you have to do is plug in the date/time comparison and add your server name. Its a bit rough and ready, but I'm sure you can beautify it a bit if you want.