I have a somewhat strange case to deal with...
- I have Windows Service "A".
- "A" is monitored for events in "B". "B" is an application that will restart "A" if "A" stops running.
- "A" should not be restarted if the user manually shuts "A" down from the Services app in Windows, or from the command prompt using a net stop on it. Basically, whenever a non-application (i.e. human) stops it, I don't want it to restart "A".
Here is a simple example of "B":
ServiceController controller = new ServiceController(someServiceName);
while (true)
{
controller.WaitForStatus(ServiceControllerStatus.Running);
controller.WaitForStatus(ServiceControllerStatus.Stopped);
controller.Start();
}
Since a user will cause the service's status to invoke a stop the same way another application will, is there any way to detect who actually stopped that particular Windows service? Is there a way to detect if an actual person stopped that particular service?