Issue
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:
-
Open a remote desktop connection
-
Check ‘Don’t ask me again for connections to this computer’, click
connect -
Allow for remote desktop to load
-
Disconnect
Attempted to run the remote desktop connection with mstsc.exe, but got the error
The shortcut name is
My code so far
Have also tried Run("C:\Users\Public\Desktop\RDP Consoles\[email protected]")
to no avail.
Anyone know why I am getting this error? Or of a better way to perform this task?
Solution
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\[email protected]
. 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\[email protected]"', '')
Answered By – Stephan
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0