0

I built a program that will connect to a list of remote machines through Windows. The only issue I'm having is that after it connects to the Remote Desktop the Windows command prompt is in a "frozen state" until I disconnect from the remote. At the point it loops the code back where you can select another machine.

I want it to be able to loop back without having to disconnect so I can connect to multiple machines.

Here is my code:

:deployCode
cmdkey /generic:"SERVERNAME" /user:"user" /pass:"password"
mstsc /v:"SERVERNAME"
cls
goto :machinelist

It doesn't step through the cls clear command and go back to my machine list (goto :machinelist) until I close the server I connect to.

I tried using "&" to join the two commands but that did not work.

i.e mstsc /v:"SERVERNAME" & goto :machinelist

How can I step to cls and goto :machinelist without having to disconnect after mstsc?

Ross Ridge
  • 38,414
  • 7
  • 81
  • 112
JohnnySemicolon
  • 255
  • 2
  • 8

1 Answers1

1

mstsc does not return if within a script. Prefix by "start" it will work (just tested here)

:deployCode
cmdkey /generic:"SERVERNAME" /user:"user" /pass:"password"
start mstsc /v:"SERVERNAME"
cls
goto :machinelist
Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219