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!
