Connect to disconnected RDP remote connection using tscon

Na Wang 6 Reputation points


I use the following command to active connection.
for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do ( %windir%\System32\tscon.exe %%s /dest:console )
and I save it as a bat file and use jenkins job to trigger it, then the RDP is locked. but it failed if I run the job again due to the RDP is disconnect by now.

Another problem is if I lock RDP by this bat file, how to keep the console always active? because I run the desktop automation scripts on the remote machine.
after lock the RDP by the jenkins job, run the script job failed in a few hours later, and the reason for failure is loses focus.
If I lock the RDP and run the script job immediately, the script can be run successfully.

Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,289 questions
0 comments No comments
{count} votes