What happens when you do not log off from Remote Desktop?
When a user closes the Remote Desktop client window by simply clicking the X in the upper-right corner without logging off, or disconnects the session from Start, their session enters disconnected mode. In this mode, all applications, open files, and windows continue running on a Remote Desktop server.
The user's RDP session will remain disconnected until the user or administrator ends it, or until the computer restarts. This can be convenient, since users can reconnect at any time, resume their Remote Desktop session, and continue working with running programs or open files.
However, these sessions can sometimes lock open files on your file server or cause data to be saved incorrectly in applications, roaming profile folders, or user profile disks.
How to set a time limit for disconnected sessions
With the quser command, you can see when a user's RDP session started, how long it has been idle, and its current status:
C:\Users\administrator>quser
NOMBRE USUARIO NOMBRE SESIÓN ID. ESTADO TIEMPO IN. TIEMPO SESIÓN
>administrator console 2 Activo 12:42 2/6/2021 8:58
user 3 Desc . 2/6/2021 12:34The Windows Remote Desktop service provides the following options for configuring Remote Desktop timeouts:
- Establecer límite de tiempo para la sesión desconectada.
- Establecer un límite de tiempo para las sesiones de Servicios de Escritorio remoto activas pero inactivas: this policy allows you to end idle RDP sessions with no user input (such as moving a mouse or typing on a keyboard).
- Establecer un límite de tiempo para las sesiones activas de Servicios de escritorio remoto: this is the maximum duration of any RDP session (including an active one), after which it is disconnected.
- Finalizar sesión cuando se alcanzan los límites de tiempo: sets the time after which an RDP session will be ended (logged off) instead of disconnected.
- Establezca un límite de tiempo para el cierre de sesión de las sesiones de RemoteApp.
By default, these options are neither enabled nor configured. To automatically end disconnected RDP user sessions, enable the "Establecer límite de tiempo para sesión desconectada" policy and select the time from the drop-down list.
This option is located in the corresponding GPO section below. You can access it by entering gpedit.msc in Run (local computer), or, if you have Active Directory, by using gpmc.msc. The section is "Configuración del equipo", "Políticas", "Plantillas administrativas", "Componentes de Windows", "Servicios de escritorio remoto", "Host de sesión de escritorio remoto", and then "Límites de tiempo de sesión".
After making the change, save it and update the Group Policy settings on your RD server (gpupdate /force). The change is not retroactive; it will only apply to new RDP sessions.
An alternative way to set RDP session time limits is through the Windows registry. Under "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services", the DWORD values correspond to the policies described above and can be modified there.