When working remotely over Remote Desktop Protocol (RDP), it’s crucial to ensure that background processes — such as programs, scripts, or macros — continue running even if the RDP session is interrupted. By default, Windows Server may terminate these processes when a session disconnects, which can lead to data loss or halted automation.
To prevent this, you need to configure RDP session timeouts via Remote Desktop Services (RDS) and Group Policy settings. This guide will walk you through the process step by step.
Install Remote Desktop Services Role
To manage session limits and enable related policies, you must first install the Remote Desktop Services role.
- Open Server Manager.
- Click Add Roles and Features.
- In the wizard, on the Before You Begin screen, check “Skip this page by default” (optional), then click Next.
- Choose Remote Desktop Services Installation and proceed.
- Select Multipoint Services as the deployment type (default).
- Choose the local server for installation.
- Check the box Restart the destination server automatically if required, then click Next or Install.
- Wait for the installation to complete.
Once the setup completes and shows "Success", close the wizard.
2. Configure Group Policy for RDP Session Timeouts
You now need to adjust Group Policy settings to control how sessions behave when disconnected or idle.
- Open Group Policy Editor
- Press Win + R, type gpedit.msc, and press Enter.
gpedit.msc
Navigate to the following path:
Computer Configuration → Administrative Templates → Windows Components → Remote Desktop Services → Remote Desktop Session Host → Session Time Limits
Enable the Following Policies:
- Policy Name Description
- End session when time limits are reached Ensures the session is properly closed after timeout. No time value is required — just set it to "Enabled".
- Set time limit for active but idle Remote Desktop Services sessions Specifies how long an idle session stays connected before being ended.
- Set time limit for disconnected sessions Defines how long a disconnected session remains active in the background.
How to Edit a Policy
- Double-click a policy or right-click → Edit.
- In the new window, choose Enabled.
- Set the appropriate time frame (e.g., 15 minutes, 1 hour).
- Click OK.
- The actual timeout values depend on your organization's policies. A common setup is:
- Idle sessions: 30 minutes
- Disconnected sessions: 1 hour
3. Finish and Apply the Policy
After configuring the policies:
- Close the Group Policy Editor.
- Apply the new settings with the command:
gpupdate /force - You may also reboot the server to ensure changes take effect.
That’s it — your RDP session timeouts are now configured to preserve background processes even after disconnection.
FAQ: RDP Session Timeouts
- Q: Will my programs keep running after I disconnect from RDP?
A: Yes — if you've set session timeouts correctly, background processes will remain active for the defined period. - Q: What happens if I don’t configure timeouts?
A: Windows Server may terminate all running apps when a session is lost, potentially causing data loss or halted scripts. - Q: Can I apply these settings via domain Group Policy?
A: Yes. In a domain environment, use the Group Policy Management Console (GPMC) to apply settings to user groups or OUs. - Q: What’s a safe value for disconnected session timeout?
A: Typically 1–2 hours. Longer periods may consume server resources unnecessarily. - Q: Does this work on all versions of Windows Server?
A: Yes, the procedure applies to Windows Server 2008 R2, 2012 R2, 2016, 2019, and 2022, with minor UI differences.