Microsoft Remote Desktop Disconnecting

Rewards
Information in this topic applies to desktop and web applications.

When using Remote Desktop to connect to a remote computer, closing Remote Desktop locks out the computer and displays the login screen. In the locked mode, the computer does not have GUI, so any currently running or scheduled GUI tests will fail.

To avoid problems with GUI tests, use the tscon utility to disconnect from Remote Desktop. tscon returns the control to the original local session on the remote computer, bypassing the logon screen. All programs on the remote computer continue running normally, including GUI tests.

FrequentlyWindows

Disconnect Manually

Microsoft
  • Remote Desktop Connection constantly disconnecting and reconnecting. I have installed Windows 10 on five computers or my home network and I am finding that connections established Using Remote Desktop Connection keep dropping out after about 10 seconds. This happens with connections between any two computers.
  • RDP: Connecting, Disconnecting, and Signing Out of User Account while in RDP (Windows 10) 1 As of 6/24/20 Summary: The following instructions will explain how to utilize remote desktop access (RDP), allowing users to connect to and disconnect from a remote desktop. These instructions also explain.

Remote Desktop disconnects frequently in Azure VM.; 5 minutes to read; g; m; v; In this article. This article explains how to troubleshoot frequent disconnections to an Azure virtual machine (VM) through Remote Desktop Protocol RDP). Sep 02, 2013 I am not convinced this would rectify the issue, the remote desktop session is not taking place through remote web access (even though it disconnects from there as well) but using the built in remote desktop client in windows. It doesnt time out after a set period of time either, sometimes it is several minutes, 10-15 maybe, whilst at other times it is less than 5 minutes, or even seconds (20.

To disconnect from Remote Desktop, run the following command on the remote computer (in the Remote Desktop Connection window) as an Administrator, for example, via the command line:

Microsoft

%windir%System32tscon.exe RDP-Tcp#NNN /dest:console

where RDP-Tcp#NNN is the ID of your current Remote Desktop session, for example, RDP-Tcp#5. You can see it in the Windows Task Manager on the Users tab, in the Session column.

Windows Remote Desktop Disconnects Frequently

Note:The Session column is hidden by default. To show it, right-click somewhere within the row that displays CPU, Memory, and so on, then choose Session in the opened context menu.

You will see the Your Remote Desktop Services session has ended message, and the Remote Desktop client will close. But all programs and tests on the remote computer will continue running normally.

Disconnect via a Batch File

You can automate the disconnection procedure using a batch file. On the remote computer, do the following:

  1. Create a batch file with this code:

    for /f 'skip=1 tokens=3' %%s in ('query user %USERNAME%') do (
    %windir%System32tscon.exe %%s /dest:console
    )

  2. Create a desktop shortcut to this file. To do this, right-click the batch file and select Send to > Desktop (create shortcut).

  3. In the shortcut properties, click Advanced and select Run as administrator.

  4. Double-click this shortcut on the remote computer (in the Remote Desktop Connection window) or call this batch file at the beginning of your tests (provided that the tests are run as an Administrator).

Important Notes

  • tscon leaves the remote computer unlocked, which can reduce the system security. You can lock the computer after the test run is over using the following command:

    Do not lock the remote computer while your automated tests are still running. If the tests need to interact with the GUI, they will fail since the operating system will stop drawing the GUI. For more information about this, see Running Tests on Locked Computers.
  • If the rdpclip.exe process is running on the remote computer and the clipboard is not empty when you disconnect from the remote session, the rdpclip.exe process can fail.

    To avoid this issue, you can terminate the rdpclip.exe process before disconnecting from the session.

Microsoft Rewards

See Also

Microsoft Remote Desktop Disconnecting System

Running Tests via Remote Desktop
About Running Tests via Remote Desktop
Running Tests in Minimized Remote Desktop Windows
Running Tests on Locked Computers