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

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


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


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


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


  • Make sure the robot is installed in Service Mode.
  • Add machine credentials for the robot account in the Unattended robot settings.
  • 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.

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.