AutoIt RDP 连接

AutoIt RDP connect

在确定 win10 上的 RDP 自动化时遇到一些问题。非常感谢你们得到的任何提示。

我想要完成的事情:

使用 AutoIt 脚本可以:

  1. 打开远程桌面连接

  2. 选中“不再询问我是否连接到这台计算机”,点击 连接

  3. 允许加载远程桌面

  4. 断开连接

已尝试 运行 与 mstsc.exe 的远程桌面连接,但出现错误

快捷方式名称是

到目前为止我的代码

也试过Run("C:\Users\Public\Desktop\RDP Consoles\administrator@windows-1")没用。

有人知道我为什么会收到这个错误吗?或者有更好的方法来执行此任务?

Run()实际上启动了一个cmd进程,所以你也必须遵守cmd的规则。

cmd 期望带空格(和一些其他“毒字符”)的文件名被引用(并且必须是双引号)。在您的示例中,您 运行 mstsc 具有 两个 参数:C:\Users\Public\Desktop\RDPConsoles\administrator@windows-1。要使它成为一个参数,引用它。最佳实践:同时引用任何路径或文件名(再次避免空格问题):

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

没有。在我的 Win 7 Ultimate 和我的 Windows Server 2019 上,它肯定是这样工作的:

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}")