14,895 pts.
 Automating a Remote desktop connection
I have written a batch file that part of its function is to initiate a remote desktop connection with another computer on the network. When the batch file gets to the remote connection command, the remote connect window appears and I have to press the "connect" button for the process to continue. The remote desktop app already has the address, and log on credentials in it. How can I have this connection happen as part of the batch file? Below is the troublesome part of my batch file:
rem Runs Access with Autoexec macro that will generate updated parts table then exit
"C:Program FilesMicrosoft OfficeOfficemsaccess.exe" "C:webqueryparts.mdb" /excl

rem Starts Remote Desktop for webquery machine
%SystemRoot%system32mstsc.exe
Thanks! -Flame

Software/Hardware used:
ASKED: February 25, 2009  7:57 PM
UPDATED: February 11, 2011  4:36 PM

Answer Wiki:
When Remote Desktop Client (mstsc) is used interactively, it offers the last used connection as the default. That's why "enter". works. From a batch file, use a connection file or the /v switch. <a href="http://technet.microsoft.com/en-us/library/cc753907.aspx">TechNet reference</a>
Last Wiki Answer Submitted:  February 25, 2009  8:25 pm  by  Rklanke   1,235 pts.
All Answer Wiki Contributors:  Rklanke   1,235 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

If you right click on the remote connection executable you get remote desktop connection properties. On the shortcut tab modify the Target line, you can add the /v <computer name or ip address> at the end of the dos line that starts the rpc executable. This would then appear as %SystemRoot%system32mstsc.exe /v <computer name or ip address>. As long as you have saved the connection settings for the computer name or IP address of the desktop you are connecting to, this will work and you don’t need the batch file.

 35 pts.

 

Forgot to say, this will make the connection when you then click the rpc shorcut with the modified target, without having to click the connect button.

 35 pts.

 

or write your line in the batch file as %SystemRoot%system32mstsc.exe /v <computer name or ip address>

 35 pts.