Windows Session Locked Error

Hi,

We came across one issue reported by the Developer that he is getting the below error in orchestrator logs while schedule ran as unattended and Robot running as service mode. FYI we are using AWS workspaces as VM’s for Robot Machines.

System exception.Cannot bring the target application in foreground because the Windows session is locked.

Also got the below error in the next step while taking the screenshot.

Take screenshot: System.ComponentModel.Win32Exception (0x80004005): The handle is invalid at System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation) at System.Drawing.Graphics.CopyFromScreen(Point upperLeftSource, Point upperLeftDestination, Size blockRegionSize, CopyPixelOperation copyPixelOperation) at UiPath.Vision.UiImage.FromScreenRegion(Rectangle region) at UiPath.Core.Image..ctor(Region screenRegion)

So, wanted to know in which case we will have this error messages.

Did this occur when the screen is locked but I tried manually locking the screen of robot machine while job is executing but I see still Job can continue by unlocking the screen. So could you please clarify on this?

One more thing I see from EventViewer logs when this error occurred is below UiPath.Executor 22.10.4.0 UiPath.Core.ImageOperationException: System.ComponentModel.Win32Exception (0x80004005): The handle is invalid at System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation) at System.Drawing.Graphics.CopyFromScreen(Point upperLeftSource, Point upperLeftDestination, Size blockRegionSize, CopyPixelOperation copyPixelOperation) at UiPath.Vision.UiImage.FromScreenRegion(Rectangle region) at UiPath.Core.Image..ctor(Region screenRegion) —> System.ComponentModel.Win32Exception: The handle is invalid at System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation) at System.Drawing.Graphics.CopyFromScreen(Point upperLeftSource, Point upperLeftDestination, Size blockRegionSize, CopyPixelOperation copyPixelOperation) at UiPath.Vision.UiImage.FromScreenRegion(Rectangle region) at UiPath.Core.Image..ctor(Region screenRegion) — End of inner exception stack trace — at UiPath.Core.Image..ctor(Region screenRegion) at UiPath.Core.UiElement.ScreenshotUnsafe()

Please let me know if this error occurs also if we are using any particular UiPath activity in the code?

So, please suggest the solution to implement or avoid these errors?

Thanks a lot!

@Rama_Thota

The user needs to be signed out before the automation starts..disconnecting or closing the vm before signout can cause errors like this

Cheers

1 Like

Hi @Rama_Thota

Please follow the steps mentioned in below post and verify the same at your end, should help you

Regards
Sonali

@Rama_Thota

Check that VM is in opened state.
Signout from that VM and run the execution if you configured unattended license as properly.

And try to look below thread solutions as well

Happy Automation!

Hi all,

Thanks for the feedback. I will check all the recommended steps.
Before that I wanted to confirm on one thing that is if my Robot is installed in service mode or user mode. As I see attached services running in the machine, can you please check and confirm

image2

Also can you please let me know best way to confirm on the mode of installation done.

Thanks!

Hi @Rama_Thota

If you follow steps in post I shared above, you will be able to confirm the same from services. If you see UiPath robot service running there, it means it’s installed in service mode.