Session logged out after disconnection of remote connection

10,601

On the Windows 7 server :

  1. Start gpedit.msc
  2. Browse to :
    Computer Configuration --> Administrative Templates --> Windows Components --> Remote Desktop Services --> Remote Desktop Session Host --> Session Time Limits.
  3. Enable "Set time limit for disconnected sessions" and set it to Never.
  4. Use regedit to go to the key
    HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services
    and ensure that MaxDisconnectionTime is set for the amount of time you want to set as the time limit in milliseconds (12 hours = 43200000). If it does not exist, create it as New DWORD (32-bit). (more info.)
  5. Reboot.
  6. Verify after reboot that the above registry setting has not changed. (In a domain, the domain settings may override local ones.)

If this doesn't work and your server is in a domain, have the IT people check in your OU the setting of "Terminate disconnected session".

Share:
10,601

Related videos on Youtube

samyb8
Author by

samyb8

Updated on September 18, 2022

Comments

  • samyb8
    samyb8 over 1 year

    I remote from my home PC (Windows 10) to my work computer (Windows 7) and every time I disconnect my remote connection (or just close it), after some time (around 1 hr) the work Windows session logs out and next time I remote or when I get to work the next day, I find my session logged out. All my open software closes, of course.

    We tried the following solution:

    https://serverfault.com/questions/269438/how-to-stop-remote-desktop-from-closing-my-session-due-to-inactivity

    But nothing has been solved. It seems to be a timeout issue after remote disconnection, but I cannot find the config for this.

    Any known solution for this?

    • boot13
      boot13 over 8 years
      It should just automatically lock the session, not log you out. Could it be a power saving setting? If it's a work computer you're connecting to, there could be group policy related to security in play. Do you have a Windows server at work?
    • samyb8
      samyb8 over 8 years
      Yes, windows server but the IT people have checked all settings and there is nothing at the server level. It is only my session which gets logged out. Not locked... completely logged out and all programs are closed!!
    • boot13
      boot13 over 8 years
      Group policy sometimes goes bonkers. Or they overlooked a GPO setting. But I bet that's what it is. Do you have another account you can log in with (to the domain) as a test? If so, log in remotely from the same machine, with that other user. Does it make any difference? If it does, then you're looking at a user policy rather than a machine policy. See social.technet.microsoft.com/Forums/windowsserver/en-US/…
    • harrymc
      harrymc over 8 years
      On the Windows 7 server, start gpedit.msc, browse to Computer Configuration --> Administrative Templates --> Windows Components --> Remote Desktop Services --> Remote Desktop Session Host --> Session Time Limits. Enable "Set time limit for disconnected sessions" and set it to Never. Reboot and test. Verify after reboot the registry setting described here. If this doesn't work and your server is in a domain, have the IT people check in your OU the setting of "Terminate disconnected session".
    • Ferrybig
      Ferrybig over 8 years
      Can the problem be related to a windows update failing to install and it tries to install itself every night, an easy to check problem
  • Luiz Palte
    Luiz Palte over 8 years
    The problem may be caused by GPO - this solution may fix it, but it depends on the Group Policy. It may overrule this setting every time its applied. But this is definitely the solution :)
  • Vojtěch Dohnal
    Vojtěch Dohnal over 8 years
    Why to edit registry and not just set the value Set Time Limit for Idle Remote Desktop Services Sessions? This RDP settings are usually set in GPO, so they will have little impact in corporate network anyhow. In fact it will be necessary to wite a script that would modify registry keys every minute to keep up with GPO refresh interval.
  • harrymc
    harrymc over 8 years
    @VojtěchDohnal: Because MaxIdleTime can be overridden, I counseled verifying it after the boot. Remark that this post is for a disconnected session, not for idle one.
  • Vojtěch Dohnal
    Vojtěch Dohnal over 8 years
    So why not just add MaxDisconnectionTime registry key if MaxIdleTime is not needed? This answer seems to me too similar to what OP has specified as already tried solution.
  • harrymc
    harrymc over 8 years
    Oups, I did mean MaxDisconnectionTime. Corrected. Apparently the poster didn't need to go that far. Thanks.
  • harrymc
    harrymc over 8 years
    @VojtěchDohnal: You misunderstood: This was a verification method only for finding out via the registry whether a domain policy was overriding this setting.