RPA Bot Fails with "SendKeys Access Denied" Error When RDP Session Disconnects

abhipraydj24
Tera Contributor

Hello ServiceNow Community,

I am facing an issue with an unattended bot process we have developed. This process uses SendKeys to interact with the ServiceNow application and runs smoothly when we are connected to the Windows Server 2019 via RDP. However, the process fails when the RDP session is disconnected, with the following error:

Component 'SendKeys' failed to execute in the activity 'Main'.
1. Exception has been thrown by the target of an invocation.
2. Access is denied.


I suspect the issue might be related to how the bot interacts with the keyboard device or screen when the RDP session is disconnected. Could this be due to:

  1. ServiceNow application limitations?
  2. The bot process being unable to locate the required input device (keyboard or screen)?

Steps Tried So Far:

  • Ensured the bot has sufficient permissions.
  • Verified the process works perfectly when the RDP session is active.

Questions:

  1. Is this issue related to ServiceNow, or is it a bot/automation tool limitation when the session is disconnected?
  2. Are there any best practices or solutions (e.g., session managers, RDP alternatives, etc.) to keep the session alive or bypass the need for an active session?

Any insights or recommendations would be greatly appreciated!

Thank you!

#ServiceNow Automation Engine RPA Hub

2 REPLIES 2

Swathi Pavani1
ServiceNow Employee
ServiceNow Employee

Hi @abhipraydj24 

The issue you're encountering occurs when focus is lost from the captured screen or component. To resolve this, please ensure that the element is fully loaded before proceeding. You can use the WaitForCreate method to verify this. Once the element has loaded, apply the Focus method to both the captured screen and the element. Afterward, you can proceed with the SendKeys method to input keystrokes or perform the desired action on the screen or control.

Regarding the error message:

  • Component 'SendKeys' failed to execute in the activity 'Main'.
    1. An exception has been thrown by the target of an invocation.
    2. Access is denied.

These errors typically indicate that the target control might not have the required focus or permission for the operation.

If this resolves your issue, please click "Helpful" to let others know.

 

Thanks

Neha Prasad
Tera Contributor

Hi @abhipraydj24 - were you able to resolve your this issue with sendKeys? We face same problem.