Hi,
I am struggling finding a way to disconnect automatically an RDP session so the remote test computer does not lock its session and makes failing the test execution (white screens due lock session).
I looked closely at the article - Disconnecting From Remote Desktop While Running Automated Tests
https://support.smartbear.com/viewarticle/72794/
Through a batch file, it is possible to disconnect so with the following batch file
for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (
%windir%\System32\tscon.exe %%s /dest:console
)
Manually in a command prompt, as admin, the command works fine.
However, When it comes to run it through TC11 I do not manage to use this batch file whether it is
- a Keyword (cannot get started the command line prompt as administrator, whereas I set the TestedApp to Run as and TestComplete is run as admin) or
- or a vbscript. Here is my code
Sub SafeRDPDisconnection()
Dim WScriptObj, ExecOperation, ExCode, StdOut
Set WScriptObj = Sys.OleObject("WScript.Shell")
' disconnecting
Set ExecOperation = WScriptObj.Exec("cmd /c ""cd C:\my_project & disconnectRDPforTC.bat""")
' Get the operation's exit code
ExCode = ExecOperation.ExitCode
' Get the application's StdOut stream
Set StdOut = ExecOperation.StdOut
If ExCode = 0 Then
CallLog.Message("Connection succeeded", StdOut.ReadAll)
Else
CallLog.Error("Server is unavailable", StdOut.ReadAll)
EndIf
endSub
It seems that the batch file is not run as admin.
Could you please shed some light? I believe that I am close to the solution.
In advance, thank you
Regards
Thomas