Skip to content
English
  • There are no suggestions because the search field is empty.

RDP and Copia Agents

Keeping Agents logged in over RDP

Problem

Remote Desktop Protocol (RDP) is commonly utilized by organizations to access Agent PCs. However, by default, RDP leaves the Agent in a state where the screen is locked at the "logon" dialog.  This can cause issues with some integrations, as the Copia Agent may require the desktop session to remain unlocked, as discussed in the prior section.  

Solutions

To address the challenge of maintaining an unlocked Agent at customer sites, many strategies can be used, detailed below:

1. Auto-Logon Configuration and Reboot Batch File
If the Agent PC is set up for auto-logon—recommended due to potential IT updates requiring a PC reboot—users can opt to reboot the PC instead of logging off.  A batch file can be placed on the remote Agent PC’s desktop (or a shortcut to the batch file) with the following command: 
shutdown -r -f -t 2

Here, -r denotes a reboot, -f forces the reboot, and -t 2 initiates a countdown from 2 seconds. After completing operations, the user can execute this batch file (or its shortcut), which will disconnect the session, reboot the PC, and automatically log in, thereby restoring the PC to its original unlocked state.


2. Batch File for Windows or Windows Server
For systems running Windows or Windows Server (and potentially other operating systems with similar functionality), a batch file can be placed on the remote Agent PC’s desktop (or a shortcut to the batch file). After completing operations, the user should run this batch file (or its shortcut) as an Administrator. This script will disconnect the session and redirect the PC back to the console session, maintaining the PC in its original unlocked state. Below are two examples of such batch files:

  1. for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do 
    ( %windir%\System32\tscon.exe %%s /dest:console )
    Save this script as a .BAT file and create a desktop shortcut to it. In the shortcut properties, select "Advanced" and choose "Run as Administrator."
  2. tscon 1 /dest:console
This command assumes that the RDP session is Session 1, which is typically the case unless multiple RDP sessions are active. To confirm the active Session ID, use the qwinsta command.

Save this script as a .BAT file and create a desktop shortcut to it. In the shortcut properties, select "Advanced" and choose "Run as Administrator."