Click 'LABEL': Cannot bring the target application in foreground because the Windows session is locked

  • Make sure the robot is installed in Service Mode.

Note: If you cannot find the UiPath Robot service in Start → services.msc, that means you installed the robot in User Mode.

To install the robot in Service Mode via the GUI installer UiPathStudio.msi, you will need to select CustomInstall for all users on this computerUnattended Robot

Reference: Robot - Installing the Robot

To install via command lines, you will need to adapt the example commands which mentions Robot as a Windows service.

The examples can be found here Studio - Command Line Parameters

  • Add machine credentials for the robot account in the Unattended robot settings.

Run the below command in a powershell.exe console in the Robot machine and then restart the UiPath Robot service.

[Environment]::SetEnvironmentVariable("UIPATH_HEADLESS_WITH_USER", "True", "Machine")

Reference: Robot - Background Process Automation

  • Make sure that your unattended robot is logged out not disconnected when you are running the job.
  • Try to play in the Orchestrator → Robot settings LoginToConsole set to Yes/No.

If you set the LoginToConsole set to Yes, you are using a Console session, if you set to No, you are using an RDP session.

  • If you have UI interactions in your process, it shouldn’t be set as Background

Example:

image

If you have Ui interactions in your project, open your project in Studio → Project Settings → set the Starts in Background option to No and republish the process

image

Reference: Studio - Background Process

7 Likes