Services - Get state
Declaration
<AMSERVICES ACTIVITY="state" SERVICE="text" REMOTEMACHINE="text" REMOTEDOMAIN="text" REMOTEUSERNAME="text" REMOTEPASSWORD="text (encrypted)" RESULTVARIABLE="text" />
Description
Retrieves the state (for example, stopped, running, paused, etc.) of a particular service and populates a variable with the result. This activity supports local or remote services.
Practical usage
Ideally used to determine the current status of a local or remote service. With this activity, a task can be created to open an Excel file of computer names and check the service state on each of them. Thereafter, it can save the results in another log file.
Parameters
Service
Property | Type | Required | Default | Markup | Description |
---|---|---|---|---|---|
Service name | Text | Yes | (Empty) | SERVICENAME="Task Scheduler" | The name of the service in which to retrieve information about. This value can be entered manually or by pressing the down arrow to allow selection from a drop-down list of currently running services. This parameter supports entry of the "Service Name" or "Display Name" as specified in the Services console (services.msc) under the General tab properties of the service. |
Include devices in the list of services (local connection only) | --- | --- | --- | --- | If
enabled, indicates that device drivers will be included in the
Service name parameter's
drop-down list of services. This parameter is disabled by default
and is not available if a remote service is specified. NOTE: This parameter does not contain markup and is only displayed in visual mode for task construction and configuration purposes. |
Place result into variable | Text | Yes | (Empty) | RESULTVARIABLE="VariableName" | The
Automate Desktop variable to populate with the state of the service. Possible
values for a service state are:
|
Computer
Property | Type | Required | Default | Markup | Description |
---|---|---|---|---|---|
Local computer | --- | --- | --- | --- | If
enabled, indicates that this activity will be performed on a service
located on the local computer. This parameter is enabled by default.
If this parameter is selected, the Another
computer parameter becomes inactive. NOTE: This parameter does not contain markup and is only displayed in visual mode for task construction and configuration purposes. |
Another computer | --- | --- | --- | --- | If
enabled, indicates that this activity will be performed on a service
located on a remote computer. The parameters below become active
if this parameter is enabled. NOTE: This parameter does not contain markup and is only displayed in visual mode for task construction and configuration purposes. |
Computer | Text | Yes, if set to Another computer | (Empty) | REMOTEMACHINE="MachineName" | The computer name of the remote machine in which to connect to. |
Domain | Text | Yes, if set to Another computer | (Empty) | REMOTEDOMAIN="DomainName" | The domain that the remote machine belongs to. |
Username | Text | Yes, if set to Another computer | (Empty) | REMOTEUSERNAME="Username" | The username to use to sign in to the remote machine. This user must have the appropriate permissions to modify services on the remote machine. |
Password | Text | Yes, if set to Another computer | (Empty) | REMOTEPASSWORD="password" | The password to use to authenticate with the Username parameter. |
Examples
- Copy and paste the sample AML code below directly into the Task Builder Steps Panel.
- To successfully run the sample code, update parameters containing user credentials, files, file paths, or other information specific to the task to match your environment.
Description
This sample task gets the current state of the "DNS Client" service and displays it in a message dialog.
<AMVARIABLE NAME="theState" />
<AMSERVICES ACTIVITY="state" SERVICE="DNS Client" RESULTVARIABLE="theState" />
<AMSHOWDIALOG WINDOWTITLE="Service State">The "DNS Client" service is in the following state: %theState% </AMSHOWDIALOG>