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

Hello,
I added a trigger to an unattended robot,
The robot triggered in time but I got this error: Click ‘LABEL’: Cannot bring the target application in foreground because the Windows session is locked.

1 Like

@dhouha.cherif

I guess the bot machine is not logged out properly…please make sure to signout before you run the bot

Cheers

Can you give me more details please
I did not get you very well

@dhouha.cherif

Before running the bot in un attended …your bot machine on which it is running should be logged out so that when bot is triggered it logs in and performs the actions

Or while running the bot either the machine is locked or is minimized so bot is not able to identify

Cheers

  • 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

6 Likes

Hi @dhouha.cherif ,

The main reason for this error is installing the robot in user mode instead of service mode. If you install the robot in user mode it does not have capability to run the process in un attended mode and in the first ui element action it will fail saying that cannot bring application to foreground and the windows session is locked so bot don’t have capability to make rdp connection to the Vm.

Solution would be select the un attended robot option while installing the studio and in advanced options you can check the check box to enable studio to install the bot in service mode. Thanks

Hi guys, I got the same issue. Here’s my situation:

  • I used the community cloud orchestrator

  • The VM doesn’t have a password

  • When I sign out of the user, the unattended job CANNOT start and on Orchestrator, the robot appears to be unlicensed
    image 422x189

  • When I lock the screen, the unattended job CAN start, but run into exception “Cannot bring the target application in foreground because the Windows session is locked.”

  • Sometimes, the UiPath Assistant suddently lost connection

  • I tried to uninstall and reinstall UiPath Studio, but there’s no screen to choose service mode or user mode. It goes straight to User mode
    Please give me some instructions, it really affects my daily automation

To install in Service Mode, you need to run the installer with an Administrator user and in the first window choose Custom → Unattended robot.

More details here: Installing the Robot

1 Like

Should i reinstall the UiPath studio on my machine?

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.