-1

Having some issues figuring out automation for RDP on win10. Would appreciate any tips you guys got.

What I am trying to accomplish:

Use an AutoIt script to:

  1. Open a remote desktop connection

  2. Check 'Don't ask me again for connections to this computer', click connect

  3. Allow for remote desktop to load

  4. Disconnect

Attempted to run the remote desktop connection with mstsc.exe, but got the error

enter image description here

The shortcut name is

image.png.49080350cbb44767fea27ea67c795b88.png

My code so far

enter image description here

Have also tried Run("C:\Users\Public\Desktop\RDP Consoles\administrator@windows-1") to no avail.

Anyone know why I am getting this error? Or of a better way to perform this task?

2 Answers 2

0

Run() actually starts a cmd process, so you have to obey the rules of cmd too.

cmd expects filenames with spaces (and some other "poison chars") to be quoted (and it has to be double-qoutes). In your example, you run mstsc with two parameters: C:\Users\Public\Desktop\RDP and Consoles\administrator@windows-1. To make it one parameter, quote it. Best practice: also quote any paths or filenames (to again avoid problems with spaces):

$x=Run('"C:\Windows\system32\mstsc.exe" "C:\Users\Public\Desktop\RDP Consoles\administrator@windows-1.rdp"', '')
0

Nope. On my Win 7 Ultimate and my Windows Server 2019 it sure works this way:

Run("C:\Windows\system32\mstsc.exe")
WinWaitActive("Remote Desktop Connection","")
Send("Put your Remote Desktop IP here")
Send("{ENTER}")
WinWaitActive("Windows Security","")
Send("Put your Remote Desktop user name here")
Send("{TAB}")
ClipPut("Put your Remote Desktop password here")
Send("^v")
Send("{ENTER}")
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.