This release task can be used with Visual Studio Team Services or With TFS 2015.2.1 onwards, to restart a windows service with all its dependent windows services, currently running. Source code available in github.
Task requires one mandatory parameter Service Name. For this parameter Service Name or Service Display name can be provided.
Once run it will stop all dependent services that are running currently, and restart the main service, then start the dependent services stopped earlier. The dependent services that were not running when the restart request made, will not be started, so that the system services state will remain same after restart service script run.
If the agent is running with non administrator account like NetworServices account, task will fail with an error. For example attempting a restart of w3svc might fail with below error.