RPA on Virtual Server

Depending on the process you wish to automate and how you intend to run the robots, your server will need to meet specific requirements for the robot to operate well.

Processes can be divided into two types: those that require a graphical interface (robots that take screenshots or use the keyboard and mouse) and those that do not (robots that emulate a terminal, automate xlsx files, use an API, etc.). It is critical to consider this when developing a robot because most servers lose the graphical interface when disconnected, causing robots to fail.

Screen locking and minimizing the remote desktop can also have an impact on your robot’s performance. The operating system should never lock the screen on a machine running an automated process (RPA), as the robot will be unable to take screenshots or move the mouse to the indicated places. When you minimize the rdp, Windows may pause some processes or remove the interface, so you must configure your machine to prevent this from happening.

In Rocketbot, we have developed an application that allows you to easily configure your server, creating the necessary.bat files to run your robot and/or modifying the registers to prevent screen problems. You can download this application here: RDP-Rocketbot. Remember to save it to the server and/or machine as needed.

Maintain interface when server disconnects.

To avoid these issues, Windows servers have a command called tscon.exe that allows you to take an open session on the server and move it to the console, giving your robot an interface to work with after disconnecting from the server.

The tscon command can be used to create a bat file in the RDP-Rocketbot application’s Disconnect and run a task or Disconnect and run ROC tabs. This file must be run as administrator each time you want to disconnect from the server (or run your robot, depending on the option selected), and it will disconnect you from the server while maintaining the graphical interface.

Beware! If the remote desktop is not opened from a physical screen, the resolution may change and become lower. Refer to section three for alternatives.

You can edit the bat and examine its contents, but we have summarized the crucial information here. The bat contains a powershell script that retrieves the session id of the session you are using when logging into the rdp and uses it in the tscon command to open the console session.

@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$sessionid=((quser $env:USERNAME | select -Skip 1) -split '\s+')[2]; tscon $sessionid /dest:console" 2> UnlockErrors.log

If you need the bat to run your robot after disconnecting, you will see something like this:

@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$sessionid=((quser $env:USERNAME | select -Skip 1) -split '\s+')[2]; tscon $sessionid /dest:console" 2> UnlockErrors.log

timeout 10
cd c:\rocketbot
rocketbot.exe -start=nombre_robot

Maintain interface when minimizing remote desktop

To minimize the remote desktop without interfering with the robot’s operation, modify the following registers in the machine that opens the rdp:

  • For the current user:
    • HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client (32 bit)
    • HKEY_CURRENT_USER\Software\Wow6432Node\Microsoft\Terminal Server Client (64 bit)
  • For all users:
    • HKEY_LOCAL_MACHINE\Software\Microsoft\Terminal Server Client (32 bit)
    • HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Terminal Server Client (64 bit)

You can change the logs with a single click in the RDP-Rocketbot application’s Connect to Remote Desktop tab. Just keep in mind that you must run the application as an administrator.

Change in resolution after disconnecting from the server

If you have already resolved the previous issues, but your robot still fails and/or does not recognize the images, you most likely have a resolution issue. We already mentioned in the first section of this post that when you disconnect the server, the graphical interface is lost and you must use tscon. This enables the robot to take screenshots, but because the server no longer has access to your screen to set a resolution, it uses its own default resolution, which is 1024×768 in most cases.

If your robot uses virtualization, this resolution change may have an impact, so it is critical that you check the resolutions that your server allows when you disconnect before beginning to develop your robot.

The resolutions allowed by the server in the Screen resolutions table from the TSCON console can be seen in the View screen resolutions tab of the RDP-Rocketbot application.

Those are the resolutions you can use, but that does not mean you can begin building the robot. When you disconnect, you should check the resolution of the server and, if possible, change it to the resolution you require. You can use the Windows module to change the screen resolution, and you can also use the Take screenshot command in the Desktop section to see if the resolution is correct.

A sample robot can be downloaded here 👇

If when exiting the remote desktop it is not possible to change the resolution manually and/or using the Rocketbot module, you can try the following:

Change the resolution in regedit by searching for all registries named DefaultSettings XResolution and DefaultSettings YResolution.

Prevent screen lock

To prevent the server from blocking the screen, you should first consult with the IT team to see if it is possible to modify the necessary settings to prevent this from happening, as this may not be possible depending on the company’s security policies.

In the Settings section of the RDP-Rocketbot application, you can modify the registers needed to disable the screen lock. The registry to be modified is HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows

Changing Policies Link