Desktop Has been disconnected while performing ui action

Hi there,

I found a way to execute a robot on a remote machine without having to remain connected to it through Remote Desktop Connection and I thought I would share. I created a batch file that contains the following:

for /f “skip=1 tokens=3” %%s in (‘query user username’) do (
%windir%\System32\tscon.exe sessionname /dest:console /password:password
)
exit

This disconnects the user from the remote machine but doesn’t lock the machine, which allows programs, including the robot, to continue to run. The batch file must be run as administrator, after the robot is started. These links provide more information: here and here.

It goes without saying this is far from an ideal solution, so tread carefully.

15 Likes