7.10. Viewing the Antecedent and Dependent Services for a Service

Problem

You want to view the services that a particular service depends on (i.e., antecedent services) and services that are dependent on that service. This is helpful to know when you want to stop a service and determine the impact it would have on other services.

Solution

Using a graphical user interface

  1. Open the Services snap-in.

  2. In the left pane, double-click on the service you want to view.

  3. Click the Dependencies tab.

Using a command-line interface:

The following command displays the services that depend on the specified service:

> sc \\<ServerName> enumdepend <ServiceName>

You can also use the following command:

> psservice \\<ServerName> 
                  <ServiceName> depend

The following command displays the services that the specified service depends on:

> sc \\<ServerName> qc <ServiceName>

Using VBScript

' This code lists the antecedent and dependent services for a service
' ------ SCRIPT CONFIGURATION ------
strService = "<ServiceName>"  ' e.g., TapiSrv
strComputer = "<ServerName>" ' e.g., fs-rtp01 (use . for local server) ' ------ END CONFIGURATION --------- set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") set colServices = objWMI.ExecQuery("Associators of " _ & "{Win32_Service.Name='" & strService & "'} Where " _ & "AssocClass=Win32_DependentService Role=Antecedent" ) WScript.Echo "Antecedent services for " & strService & ":" for each objService in colServices Wscript.Echo vbTab & objService.DisplayName next WScript.Echo ...

Get Windows Server Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.