Service package guide
Read and change the state of a local Windows service.
Version 2.17.1. Installed versions can differ. Examples are illustrative and not tested.
Prerequisites
Use Windows with this package installed. Services are local to the current Device; you cannot name a remote computer. Use the service name, such as SampleWorker; a display name might not be found. The account needs permission to read and control the service.
Pause, Resume, Start and Stop wait up to 30 seconds; you cannot change this time. If the service is already in that state, nothing changes. Every action and condition fails (it does not return an empty value or false) if the service is missing, the name is empty, you do not have the rights, or reading the state fails. A change also fails if it is not supported or 30 seconds pass (the service can still be changing). Test with a service that other programs do not use, such as a test service SampleWorker that supports pause and continue, and read its state before you change it.
Shared fields
Every action and condition uses these fields.
| Input | Editor field | Type; default; requirement | Use |
|---|---|---|---|
service | Source | Servicedefault BY_optional | BY_ reads service; BY_ reads service. The other name is ignored. |
service | Service list | Stringdefault emptyrequired for BY_ | Local service name, such as Sample; outer spaces are removed. |
service | Variable | Stringdefault emptyrequired for BY_ | Sample, or a String reference such as $service that holds it. |
Actions
Get service status (serviceGetStatus)
Read the current state without waiting for a change to finish. Use it before a branch or a change.
Inputs
Uses the shared fields.
Outputs
| Output | Type | Meaning |
|---|---|---|
result | String | Exact Windows state name, such as Running. |
Example
SampleWorker is running. Set serviceOption=BY_TEXT and serviceNameByText=SampleWorker. Bind result to String variable state.
Expected result
state is Running. Other states are Stopped, Paused, StartPending, StopPending, PausePending and ContinuePending.
Pause service (servicePause)
Pause a local service and wait for Paused. The service must support pause.
Inputs
Uses the shared fields.
Outputs
No output variables.
Example
SampleWorker is Running. Set serviceOption=BY_SELECTION and serviceNameBySelection=SampleWorker.
Expected result
Get service status returns Paused.
Resume service (serviceResume)
Resume a local service and wait for Running. The service must support continue.
Inputs
Uses the shared fields.
Outputs
No output variables.
Example
SampleWorker is Paused. Set serviceOption=BY_SELECTION and serviceNameBySelection=SampleWorker.
Expected result
Get service status returns Running.
Start service (serviceStart)
Start a local service and wait for Running. The services it needs and the rights to start it must be available.
Inputs
Uses the shared fields.
Outputs
No output variables.
Example
SampleWorker is Stopped. Set serviceOption=BY_SELECTION and serviceNameBySelection=SampleWorker.
Expected result
Get service status returns Running.
Stop service (serviceStop)
Stop a local service and wait for Stopped. Work that depends on it can be interrupted.
Inputs
Uses the shared fields.
Outputs
No output variables.
Example
SampleWorker is Running. Set serviceOption=BY_SELECTION and serviceNameBySelection=SampleWorker.
Expected result
Get service status returns Stopped.
Conditions
Service is not running (serviceIsNotRunning)
True when the service is not Running now (paused and pending count as not running).
Inputs
Uses the shared fields.
Outputs
Gives true or false.
Example
SampleWorker is Running. Set serviceOption=BY_TEXT and serviceNameByText=SampleWorker, then use the condition in a branch.
Expected result
false for Running; true for every other state.
Service is running (serviceRunning)
True when the service is Running now.
Inputs
Uses the shared fields.
Outputs
Gives true or false.
Example
SampleWorker is Running. Set serviceOption=BY_TEXT and serviceNameByText=SampleWorker, then use the condition in a branch.
Expected result
true for Running; false for every other state.