After running the desired program on the remote VPS, and closing the RDP connection, some programs stop working because the idle remote desktop session will be terminated after a short time.
In this article, we will see how to set the maximum amount of time an active Remote Desktop Service session can be idle (without user input) before it is automatically disconnected.
Through the Local Group Policy Editor
To launch the Group Policy Editor in Windows Server, run the following command in the Run window: gpedit.msc
2. In the left pane, click to expand User Configuration, Administrative Templates, Windows Components, Remote Desktop Services, Remote Desktop Session Host, and Session Time Limits.
3. In the right pane, right-click "Set time limit for active but idle Remote Desktop Services sessions" and click "Edit".
4. Remove Time Limit for Idle Remote Desktop Services Sessions
Select "Not Configured" or "Disabled". The default value is "Not Configured".
5. To set a time limit for idle Remote Desktop Services sessions:
Select Enabled.
In the "Options" section, click the "Idle session limit" dropdown and select the time you want to set as the time limit.
6. Click OK.
After these changes, you can restart the server.
Through the registry editor
1. Open the Start menu, then type regedit in the search box and press Enter.
2. If prompted by UAC, click Yes.
3. In regedit, navigate to the location below:
HKEY_LOCAL_MACHINE\\SOFTWARE\\Policies\\Microsoft\\Windows NT\\Terminal Services
4. To set a time limit for idle Remote Desktop Services sessions
In the right pane of Terminal Services, right-click an empty space, select New and DWORD (32-bit) Value, type MaxIdleTime, and press Enter. (see screenshot below)
In the right pane, right-click MaxIdleTime and select Modify.
Select Decimal, then enter the registry value in the table below for the amount of time you want to set as the time limit and click OK.
5. Remove Time Limit for Idle Remote Desktop Services Sessions
In the right pane, right-click MaxIdleTime and select Delete.
6. Close the registry editor.
7. Log out and log back in or restart your computer for the changes to take effect.
Via PowerShell
reg add "HKLM\\software\\policies\\microsoft\\windows nt\\Terminal Services" /v MaxIdleTime /d 0 /t REG_DWORD;
Then restart the server. Or a terminal server.
net stop TermService /y; net start TermService /y;
Now your terminal session will not close when there is no activity.
We also suggest you other useful articles:
- How to view RDP connection logs in Windows Server 2016, 2019
- How to enable previous session restore on Windows Server 2016, 2019?
- How to configure idle RDP session timeout
- Disable UDP for RDP connections to Windows Server