Automating a Remote desktop connection

14925 pts.
Tags:
Batch files
Remote desktop
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

Answer Wiki

Thanks. We'll let you know when a new response is added.

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.
TechNet reference

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Johnnyt3
    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 pointsBadges:
    report
  • Johnnyt3
    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 pointsBadges:
    report
  • Johnnyt3
    or write your line in the batch file as %SystemRoot%system32mstsc.exe /v <computer name or ip address>
    35 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following