Windows Service setup for Workforce Agent Core

Prerequisites

  • If you are not familiar with Windows Services, this might not be relevant for you.
  • To follow along, you will need a Robocorp account for accessing Control Room and Robocorp Workforce Agent Core. If you haven't already, you might want to first follow the Quickstart guide to get familiar with Control Room.
  • You need to have administrator permissions on the machine to set up the Windows Service.

Limitations

A Windows Service does not have UI access to applications; this means that you can run so-called headless operations and access the machine and user resources, but you cannot, for example, take screenshots of Windows application UI's.

Set up the user for the Windows Service

The setup is simple if you log in to Windows as the user you want the Windows Service to run. The permissions of this user determine what the Windows Service can access.

The reason for running robots on local machines is to have access to some user-level resources or permissions, so running the Robocorp Workforce Agent Core as a Windows Service requires you to use some existing user account that can log in to the machine. You can set up a separate local user or use an Active Directory user.

Note: Setting up this user's permissions on the machine with the principle of least privilege is the most effective way of introducing better security.

Installing the Windows Service

To help out in the setup, we provide a simple CLI helper tool to avoid as much hassle as possible on setting up Windows Services. The helper tool downloads the Robocorp Workforce Agent Core and all needed tools and sets up the service.

Steps below detail the setup.

1. Get the helper tool to the target machine

Get the Robocorp Service Helper here

2. Fill in the arguments for the helper command

The installation command will interactively ask for the logged-in user's password; it can be left empty to be set later via Windows GUI.

robocorp-service-helper.exe install

Optional arguments:

  • --name "Robocorp Workforce Agent" Name for the Windows Service / Windows task / Robocloud environment
  • --instance-path "C:\robocorp\wfa-service" Path the service uses to store run data
  • --robocorp_home "C:\robocorp\wfa-service\home" Path the service uses for environment caching
  • --domain Domain of the user the service runs as.
    • If you are running these as the targetted user %USERDOMAIN% should be a reliable way to get the right domain.
  • --username Username of the user the service runs as.
    • If you are running these as the targetted user %USERNAME% variable holds the correct name
  • --link-token <link token from Control Room>
    • Get the link token from Control Room: Go to correct workspace > Environments > Link token

      link-token

      Token is only used for linking and only valid for 1 hour, so no need to store this anywhere.
  • --ci when running from CI system to make sure the tool is non-interactive
  • --log-level DEBUG In error cases adding this will printout more details.

3. Run the helper command

helper-run

4. Define the user for the service

You can use the default Windows Services application to set the user for the service.

  • Start menu > type Services
  • Find the service name you gave to the command and open Properties.
  • Give the username and password to Log On > This account

    service-user

Note: You can also set Recovery options for the service as you choose.

5. Start the service

  • You can do this via the default Services application

    service-start

6. All done

You should now see a new environment in Control Room with the name you gave in Idle state, ready for work.

done

August 11, 2022