You can create a service on Windows depending on the other service. This means that a service will run if the service that is required is already running. How?
Windows Service is a program that runs in the background on the Microsoft Windows operating system and does not have a user interface. Windows Services are often used to perform system-level tasks, such as running background tasks, monitoring system resources, and managing system settings.
The service can be started automatically at system startup or it can be started, stopped, or paused manually by the administrator. Some examples of services included with Windows are Print Spooler, which manages print tasks, and Task Scheduler, which lets you schedule automated tasks. In addition, many third-party applications install services as part of their installation process.
Adding a service dependency is often useful to ensure that the service will run properly by making sure other services that support it are running first.
Many built-in Windows components and third-party applications have dependencies defined during installation and can be accessed from the Services GUI. To add dependencies after installation, you can use Windows Service Control (SC) commands or manually enter entries in the registry.
Add or remove Windows servicing dependencies through CMD
The first step to being able to add or remove Windows servicing dependencies through a Command Prompt (CMD) is to open and run Command Prompt (CMD) as an administrator.
Note that the “depend” command parameter will overwrite the list of existing dependencies, not add. So, for example, if Service03 already depends on Service01 and Service02, when you run the command “depend= Service04″ it will make Service01 dependent only on Service04.
1. Check service dependencies
You can use the following command to check service dependencies.
sc qc [service_name]
for example: “sc qc Spooler” to check for Windows Print Spooler dependencies.
Make a note of all dependencies from the service if you want to add dependencies, as in the next example.
Other Interesting Articles
2. Add servicing dependencies
To add dependencies, you can use the following command.
sc config Service03 depend= Service04
The command means that Service03 will not start until Service04 has already started. If you stop Service04, Service03 will stop automatically.
To add many services at once, you can use the command.
sc config Service03 depend= Service01/Service02/Service04
In that example, for example, the result of checking the service in the first step, Service03 depends on Service01 and Service02.
Then you want to add Service03 also depends on Service04, then you have to write the previous dependencies as well.
3. Remove servicing dependencies
You can’t remove any of the dependencies if a service relies on many services. All you can do is remove all dependencies by using the following command.
sc config Service03 depend=/
The command will remove all dependencies on Service03.