Search code examples
.netwindows-servicesservicecontroller

ServiceController.ExecuteCommand: how to get data back


In .NET, the ServiceController class allows you to send a custom command to a service using the ExecuteCommand method.

I would like to be able to query the service for its status (a custom notion of status, not the 'Started/Stopped' variety). I was hoping it would be straightforward to make a call to the service using something similar to ExecuteCommand and get a return value indicating the status. Is there something in ServiceController that would enable me to do this?

Assuming not, I guess I have to use some kind of external inter-process communication technique (e.g. service writes its status to a database, or to a message queue). What would you recommend for simplicity?


Solution

  • There certainly isn't a way in ServiceController. Leaving WCF as presumably the best option. Tutorials here: http://www.switchonthecode.com/tutorials/wcf-tutorial-basic-interprocess-communication