UI Automation in VM machine

Hello UiPath Community,

I’m currently facing an issue when trying to take a screenshot in unattended mode. During execution, the process fails with the following error message:

Take Screenshot: System.ComponentModel.Win32Exception (6): The handle is invalid.
   at System.Drawing.Graphics.CopyFromScreen(...)
   at UiPath.Vision.UiImage.FromScreenRegion(Rectangle region)
   at UiPath.Core.Image..ctor(Region screenRegion)

Details:

  • Process Name: SAP B1 CV Unatt Test Process
  • [Robot] Type: Unattended (swa-rpa-unattended)
  • Machine Name: SWA-RPA
  • User: SAWT\RPAUser
  • UiPath Version: 1.0.3 (process version)
  • Timestamp: 2025-10-15T22:51:31.42153-05:00

Description of the issue:
When the unattended [robot] tries to execute a “Take Screenshot” activity, the workflow throws the above error. It appears that the screenshot cannot be taken because no active desktop session exists at that moment.

What I’ve checked so far:

  • The process works fine in attended mode.
  • The unattended robot runs as a background process (service mode).
  • The error occurs right when the screenshot activity executes.

Request for help:
Could someone please advise the best practice for taking screenshots in unattended mode?
Should I configure the [robot] to log in interactively (with “Login to Console = No” and screen resolution settings), or is there a recommended headless-safe alternative for capturing images in unattended executions?

Thank you for your time and assistance!

hi, @Chandru_S configure the robot to log in interactively by setting Login to Console = No and ensure the machine has an active desktop session with a visible screen resolution

@Chandru_S,

I would suggest to try upgrading packages to the latest possible version once