Disconnecting from Remote Desktop while executing automated tests
Explains how to restore a remote desktop session to the local console of the remote computer while you are executing automated tests on the remote computer.
Problem
When using Remote Desktop to connect to a remote computer, terminating Remote Desktop locks out the remote computer, displaying the logon screen. In the locked mode, TestArchitect is unable to continue to interact with the AUT’s GUI, so any currently running automated tests might fail.
Solution
To avoid this problem, use the tscon command to disconnect from Remote Desktop. tscon returns the control to the original local session on the remote computer, overcoming the logon screen. All programs on the remote computer continue running normally, including your running automated tests.
To disconnect from Remote Desktop, run the following command on the remote computer (in the Remote Desktop window) as an administrator:
%windir%\System32\tscon.exe <SessionID> /dest:console
where <SessionID> is the ID of your current Remote Desktop session, for example, 0. You will see the Your remote desktop session has ended message, and the Remote Desktop client will be terminated. But all programs and automated tests on the remote computer will continue to run normally.
You can also automate the above disconnection step using a batch file or using the execute command built-in action.
Option #1: Using the execute command built-in action in your test procedures. On the remote computer, do the following:
- Start the TestArchitect Controller as an administrator.
- In TestArchitect Client, create the following test procedure
Option #2: Using a batch file.
Create a batch file with the following code:
%windir%\System32\tscon.exe 0 /dest:console %windir%\System32\tscon.exe 1 /dest:console %windir%\System32\tscon.exe 2 /dest:console %windir%\System32\tscon.exe 3 /dest:console %windir%\System32\tscon.exe 4 /dest:console
Create a desktop shortcut to this file. To do this, right-click the batch file, and select Send to > Desktop (create shortcut).
Right click the newly created shortcut, and click Properties.
In the Shortcut Properties dialog box, click the Shortcut tab, and click the Advanced button.
In the Advance Properties dialog box, select the Run as administrator check box, and click OK.
Now, when you need to disconnect from Remote Desktop, double-click this shortcut on the remote computer (in the Remote Desktop window). You can also invoke this batch file in your automated tests, provided that the automated tests are executed as an administrator, that is, you start the TestArchitect Controller as an administrator.