Retrieving Service Properties
Microsoft® Windows® 2000 Scripting Guide
To effectively manage services in your organization, you need a detailed understanding of the properties of those services. You need to know which services are configured to automatically start whenever a computer is started, and which services need to be manually restarted. You also need to know the user account under which each service is running and whether the service runs as part of a service group.
You can use the WMI Win32_Service class to retrieve the properties of all the services installed on all the computers on your network. Some of the important service properties available through the Win32_Service class are listed in Table 15.1.
Table 15.1 Service Properties Available from the Win32_Service Class
Property |
Description |
---|---|
AcceptPause |
Indicates whether the service can be paused. |
AcceptStop |
Indicates whether the service can be stopped. |
Description |
Description of the service. |
DesktopInteract |
Indicates whether the service can create or communicate with windows on the desktop, and thus interact in some way with a user. Interactive services must run under the Local System account. Most services are not interactive; that is, they do not communicate with the user in any way. |
DisplayName |
Name of the service as viewed in the Services snap-in. Note that the display name and the service name (which is stored in the registry) are not always the same. For example, the DHCP Client service has the service name Dhcp but the display name DHCP Client. |
ErrorControl |
Action to be taken if a service fails during startup. Values and their associated actions include:
|
ExitCode |
Error code defining any problems that were encountered when starting or stopping a service. If a service is able to properly start or stop, this value is set to 0 (no error). |
Name |
Unique name of the service as stored in the registry. |
PathName |
Fully qualified path to the executable file responsible for implementing the service. |
ProcessID |
Process identifier assigned to the service during startup. |
ServiceType |
Valid service types include:
|
Started |
Indicates whether or not the service is started. |
StartMode |
Values include:
|
StartName |
Account name under which the service runs. Although many services run under the LocalSystem account by default, services can run under any valid local or domain user account. The service is limited to the privileges and access rights belonging to that account. |
State |
Valid states include:
|
SystemName |
Name of the computer where the service is installed. This property is useful in scripts that retrieve service status from multiple computers. |
The service properties available through Win32_Service are similar to the service properties available through the Services snap-in, as shown in Figure 15.1.
Figure 15.1 Win32_Service Properties