如何从 VBScript 将文字 @ 字符作为模拟击键发送到 SSH 会话? [重复]

问题描述 投票:0回答:1

我有一个 VBScript,我希望能够在 powershell 中运行,但由于某种原因 @ 不想被打印出来。它停在“ssh root”处,然后无法继续。不要介意 x 等密码。

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "powershell.exe"
WScript.Sleep 500
WshShell.SendKeys "ssh -y -l swupdate 169.254.x.xx -o HostkeyAlgorithms=ssh-rsa"
WshShell.SendKeys "{ENTER}"
WScript.Sleep 300
WshShell.SendKeys "something"
WshShell.SendKeys "{ENTER}"
WScript.Sleep 300
WshShell.SendKeys "ssh [email protected] -y"
WshShell.SendKeys "{ENTER}"
WScript.Sleep 1500
WshShell.SendKeys "something"
WshShell.SendKeys "{ENTER}"
vbscript sendkeys
1个回答
0
投票

虽然文档中没有具体提及,但将

@
括在
{}
中似乎可以在 VBS 和 PowerShell 中使用:

WshShell.SendKeys "ssh root{@}198.19.x.x -y"
© www.soinside.com 2019 - 2024. All rights reserved.