36

I'm connecting from a windows vista desktop to a server running windows server 2003. I'm using Remote Desktop and I'm running some very long running processes on the remote server. My problem is that Remote Desktop logs out my session and terminates any running processes after some amount of time without input from myself. This means I need to sit at my pc wiggling the mouse every now and then rather than head out and enjoy the glorious sunshine for a few hours.

Does anyone know how I disable this behavior? I assume it is configurable somewhere.

1

3 Answers 3

18

Using Group Policies (best practice) Open Group Policy.

In Computer Configuration, Administrative Templates, Windows Components, Terminal Services, Sessions, enable the settings you want to configure. See the policy explain text for more information.

Or

Using Terminal Services Configuration Open Terminal Services Configuration.

In the console tree, click Connections.

In the details pane, right-click the connection for which you want to modify time-out settings, and then click Properties.

On the Sessions tab, above End a disconnected session, select the Override user settings check box. This allows you to configure time-out settings for the connection.

Configure the following time-out settings as appropriate:

In End a disconnected session, select the maximum amount of time that a disconnected session remains on the server. When the time limit is reached, the disconnected session ends. When a session ends, it is permanently deleted from the server. Select Never to allow disconnected sessions to remain on the server indefinitely.

In Active session limit, select the maximum amount of time that a user's session can remain active on the server. When the time limit is reached, either the user is disconnected from the session or the session ends. When a session ends, it is permanently deleted from the server. Select Never to allow the session to continue indefinitely.

In Idle session limit, select the maximum amount of time that an idle session (a session without client activity) remains on the server. When the time limit is reached, either the user is disconnected from the session or the session ends. When a session ends, it is permanently deleted from the server. Select Never to allow idle sessions to remain on the server indefinitely.

Source

3
  • I don't see the terminal services in the group policy...?
    – deostroll
    Jan 28, 2016 at 8:03
  • 8
    @deostroll it's been renamed to Remote Desktop Services for newer versions of Windows
    – Darwyn
    Mar 11, 2017 at 21:58
  • On client side or server side? There doesn't seem to be anything called Remote Desktop Services in Win10 Home (my client side). Did you mean that this has to be configured on the server side? (That won't work for me, because the server side is CentOS 7 Linux, not Windows.) Apr 21, 2020 at 12:49
15

I ran into the same problem, but was unable to access the Group Policy or Registry, due to restricted privileges.

However, I found another solution which uses Windows Script Host to run a piece of JScript which will toggle Scroll Lock every five minutes, for one hour.

Here's the script. Just save it with a .js extension, and run it with "Microsoft Windows Based Script Host".

    var WshShell = WScript.CreateObject("WScript.Shell");
    for (var i = 0; i < 12; i++) { // Loop 12 times
        WshShell.SendKeys('{SCROLLLOCK}');
        WshShell.SendKeys('{SCROLLLOCK}'); // Toggle Scroll Lock
        WScript.Sleep(300000); // Wait 5 minutes
    }

If you want to change the key being pressed, check out this link, and swap out the SendKeys parameter for another character.


The same solution, in PowerShell:

[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$allowCloseAfter = (Get-Date).ToUniversalTime().AddHours(24)
while ($allowCloseAfter -gt (Get-Date).ToUniversalTime()) {
    [System.Windows.Forms.SendKeys]::SendWait("{SCROLLLOCK}")
    [System.Windows.Forms.SendKeys]::SendWait("{SCROLLLOCK}")
    Write-Host '.' -NoNewline
    Start-Sleep -Seconds 300
}
4
  • caffeine.exe seems much easier, but simply doesn't work for me inside a remote session of RD, both local PC and remote PC are win10. Apr 29, 2020 at 23:30
  • For those wanting a PS version: docs.microsoft.com/en-us/previous-versions/windows/it-pro/…
    – JohnLBevan
    Nov 4, 2020 at 7:27
  • 2
    This did not keep my RDP session active.
    – RonJohn
    Dec 28, 2021 at 4:12
  • Maybe need to run this twice. On the remote desktop and on the local machine.
    – ian_scho
    Sep 27, 2022 at 12:44
14

For Windows 7/Windows 10/Windows Server 2012 and above:

  • Press Windows+R and type gpedit.msc
  • Navigate the tree view on the left to Computer Configuration/Administrative Templates/Windows Components/Remote Desktop Services/Remote Desktop Session Host/Session Time Limits
  • Adjust the four settings as desired (I believe you want to adjust Set time limit for disconnected sessions and Terminate session when time limits are reached)
1
  • 1
    I tried this but it didn't work for me. The VM is on a domain though. I am not too sure if there is a domain policy that overrides the one I set up.
    – boggy
    Sep 6, 2017 at 22:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .