msbuildtasks
msbuildtasks copied to clipboard
ServiceController: StopAndKill
I would like to propose a new feature for the ServiceController task: StopAndKill. This new command would also kill the process started by the service in addition to stopping the service.
The reason for this feature is to handle a situation whereby a service stops but its associated process continues to run. In the ideal world, this would never happen because this indicates a design flaw in the service but that's a separate rant...
The process started by a service can be easily determined using WMI (or System.Management wrapper) as shown here: http://stackoverflow.com/questions/1574019/how-to-determine-windows-diagnostics-process-from-servicecontroller
The logic would be as follows:
- Get the process ID of the process started by a service
- Stop the service
- If the process is still running, shut it down
I, of course, would be happy to implement it assuming that there are no reasonable objections from the community to this feature.