2

I created two Windows services A and B, and would like to add dependency between them so that I can:

  1. Start service A (service B starts automatically)

  2. Stop service A (service B stops automatically)

However, the command sc config ServiceA depend= ServiceB only works for:

  1. Start service A (service B starts automatically)

  2. Stop service B (service A stops automatically)

Is there any way to make service B stop automatically when I stop service A?

2 Answers 2

5

A dependency indeed only would work in a way that stopping service B would stop service A. If this is not what you want, dependencies are not for you and you would need something outside of the built-in service control mechanism doing this work. Using WMI to subscribe to an event triggered by the service stop command and some scripting to do the checks and stop the other service should do the trick.

0

If A is dependent on B then all that means is that A needs B to be running therefore - If you start A then it will automatically start B first - If you stop B then A will be stopped first

If you stop A there is no reason for B to stop - if you have access to the source code of service A you could get it to stop B programatically when itself is stopped.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .