"Cannot perform the UI action because the Windows session is locked." error

I keep getting this error -
Cannot perform the UI action because the Windows session is locked.

Full error:
Cannot perform the UI action because the Windows session is locked.
at UiPath.Core.Activities.ObsoleteTaskAsyncCodeActivity`1.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

@AutomationDude, Hope you’re doing well !!

  1. Keep the Windows session unlocked while the bot runs UI activities can’t work on a locked screen.
  2. Disable auto-lock: turn off the screensaver/“display logon screen on resume”, set screen timeout to Never, and set Interactive logon: Machine inactivity limit to 0 in Local Security Policy (or get IT to exempt the machine from the lock policy).
  3. Don’t close the RDP window to the bot machine that locks it. Instead run query session, then tscon <ID> /dest:console as admin before disconnecting.
  4. For unattended runs, configure the robot in Orchestrator as Unattended with the Windows username and password entered.
  5. Set Login to Console to No if you connect via RDP, or Yes if the bot runs on the physical console.
  6. Make sure the robot user isn’t already logged in on that machine (log out any open sessions with that user).
  7. Use Windows Pro/Enterprise/Server and run the UiPath Robot as a Windows service.
  8. Change Click/Type Into activities to Simulate or Send Window Messages input mode so they work in the background.
  9. Add Retry Scope / Try-Catch around UI steps so a temporary lock doesn’t fail the whole job.
    Cheers :blush:

Wow! this is such a comprehensive reply! I will try these and get back to you @manikandan.ckj
MUCH thanks

Hi @AutomationDude

This error usually occurs when the Robot tries to perform a UI action while the Windows session is locked.

I would check the following:

  • Verify that the Windows session is not locked when the job is running.

  • If using an Unattended Robot, check the Robot/Runtime settings and Windows login configuration.

  • If the machine is accessed through RDP, check whether disconnecting the RDP session is causing the session to lock.

  • Check the Robot/Orchestrator logs to determine when the session became locked.

  • Also verify whether the application requires an interactive desktop session for the UI activities being used.

As a first step, I would confirm the Robot’s Windows session state and RDP configuration. If the session is locked, UI-based activities may fail even though the Robot job itself is running.

Could you confirm whether this is an Attended or Unattended execution and whether you are using RDP?

@AutomationDude

Is it running in your machine or client machine?

if you are trying to run the unattended robot you must ensure that unattended robot is installed in service mode.

Check the below threads,

Sorry beginner here…where do i see if its attended?

@AutomationDude

No worries! :blush:

First, check whether you are running the automation as Attended or Unattended.

If you’re using UiPath Assistant, open it and check the Robot connection/status. Also, if you’re connecting to the machine through RDP, make sure the Windows session isn’t locked when the automation is running.

If you’re not sure which setup you’re using, you can share a screenshot of your UiPath Assistant or Orchestrator Robot settings, and we can guide you from there.

@AutomationDude Confirm where the process is running

  • Studio
  • UiPath Assistant
  • Orchestrator unattended robot
  1. If you are running from Studio/Assistant
    • Log in to the Windows machine.
    • Keep the machine unlocked.
    • Run the workflow again.
    • Do not press Win + L while it is running.
    • Also check that screen lock/sleep is not automatically happening.
  2. Disable automatic lock temporarily for testing
    • Open Windows Settings.
    • Go to Accounts → Sign-in options.
    • Check when Windows requires sign-in again.
    • Also go to System → Power & battery → Screen and sleep.
    • Increase the sleep/lock timeout.
  3. This is mainly to confirm whether auto-lock is the cause.
  4. If you are connecting through Remote Desktop
    A common issue is:
    • You connect to the robot VM using RDP.
    • Start the process.
    • Close the RDP window.
    • Windows locks/disconnects that session.
    • UiPath then cannot perform Click/Type Into/UI activities.
  5. So for testing, keep the RDP session open and run the automation again.
  6. If it works while RDP is open
    Then you have confirmed that the issue is related to the Windows interactive session.
  7. If this is an unattended robot
    Do not depend on manually keeping RDP open.
    In Orchestrator, check:
    • Tenant → Manage Access / Users
    • Confirm the Windows account used for the robot.
    • Verify the username/domain is correct.
    • Verify the unattended credentials are configured.
    • Verify the user has an Unattended runtime/license assigned.
    • Verify the machine/machine template has available unattended runtime.
  8. Run it directly from Orchestrator
    Start the job from Orchestrator instead of first logging into the VM manually.
    UiPath should create/login to the Windows session using the configured unattended credentials.

Please let me know if it works

Easy way to tell us is based on how you start the robot off.

Are you running it from the assistant, or starting a job via the Orchestrator either manually or with a time / queue based trigger?

@AutomationDude

Is this error coming when you start fromorchestrator?

If so then first tell if its happening only recently or its always like that

If recently then login to machine and signout should fix the issue..

If its always failing then first go to machine and open task manager go to services and check if userhost service is present..if yes then you need to uninstall and install robot in service mode which would create unattended robot properly

If happening in attended mode then that means you might be minimizing or closing the window ..and its not possible to access UI in that case

Cheers

Hi @AutomationDude

This error means the Windows session is locked, so UiPath cannot perform UI actions.

Please make sure the robot’s Windows session is unlocked and active while the job is running. If it’s an unattended job, also check the robot/session configuration in Orchestrator.

Thanks for all the replies guys. Robot is in attended mode. Strangely, the automation runs fine If I remove the new ‘Screenplay’ activity from workflow!! Not sure why including this activity will cause UiPath to not run. All other automations work. I use Screenplay to click in chrome on some links. Has anyone else seen this problem or any ideas?

yeah, its attended mode

yeah, from assistant

@AutomationDude

if attended

then are you minimizing or closing the vdi ?

cheers