Get Service Status

Gets the current state of a Windows service, according to its name and index.

Command availability: IBM RPA SaaS and IBM RPA on premises

Description

Gets the current state of a Windows service, according to its name and index.

Note: Windows services 🡥 are applications that run in the background and they can be automatically started when Windows starts.

Script syntax

IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.

getServiceState --name(String) (String)=name (Numeric)=number

Input parameters

The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.

Designer mode label Script mode name Required Accepted variable types Description
Service name name Required Text Name of the service from which the current state should be obtained.

Output parameters

Designer mode label Script mode name Accepted variable types Description
Service name Text Current state of the specified service.
Index number Number Service Status Index:
  • Stopped = 1;
  • StartPending = 2;
  • StopPending = 3;
  • Running = 4;
  • ContinuePending = 5;
  • PausePending = 6;
  • Paused = 7.

Example

Gets the current state of a Windows service, called "MSSQLSERVER".

defVar --name serviceState --type String
defVar --name serviceIndex --type Numeric
getServiceState --name MSSQLSERVER serviceState=name serviceIndex=number
logMessage --message "Service state: ${serviceState}\r\nService index: ${serviceIndex}" --type "Info"
// Output from example above:
// Service state: Stopped
// Service index: 1
Note:The output value depends on the application installed on your Windows device.

Limitations

Use the service name instead of the service display name for commands that handle Windows service. Ex: Use IBMAUTService and not the display name which is IBM Auto Update Service.