I'm working on a solution that contains a Windows Service and a WinForms client that interacts with that service.
In my pre-build and post-build events, I have some net start
and net stop
commands to start and stop the service, but there are times when this causes a problem (file's not found, service is already stopped, etc.).
Is there a way to test if a service is running or installed prior to issuing net start?
I'd like to put this test in .cmd file and run it in the pre-build event for the project.