Vbscript 用vbs编写Plink脚本

Vbscript 用vbs编写Plink脚本,vbscript,Vbscript,我制作了一个脚本来请求用户输入,并将其放置在vbs脚本中以运行程序。我还不太远,但它给了我一个无效字符的错误。我不确定我做错了什么 ' "strIP" is the IP address entered by the user strIP = InputBox("Please enter the IP address of the Access Point") ' "strUser" is the Username entered by the user strUser = InputBo

我制作了一个脚本来请求用户输入,并将其放置在vbs脚本中以运行程序。我还不太远,但它给了我一个无效字符的错误。我不确定我做错了什么

' "strIP" is the IP address entered by the user strIP = InputBox("Please enter the IP address of the Access Point") ' "strUser" is the Username entered by the user strUser = InputBox("Please enter the Username of the Access Point") ' "strPass" is the Password entered by the user strPass = InputBox("Please enter the Password of the Access Point") Set objShell = WScript.CreateObject("WScript.Shell") ' Command to run Plink with the user input data provided. Plink = "C:/Program Files (x86)/plink/plink.exe" sPlinkOptions = " -ssh -pw" sCommand = """" & Plink & sPlinkOptions & strPass & """ """ & strUser & ""@"" & strIP objShell.Exec(sCommand) “strIP”是用户输入的IP地址 strIP=InputBox(“请输入接入点的IP地址”) ““strUser”是用户输入的用户名 strUser=InputBox(“请输入接入点的用户名”) ““strPass”是用户输入的密码 strPass=InputBox(“请输入接入点的密码”) 设置objShell=WScript.CreateObject(“WScript.Shell”) '命令使用提供的用户输入数据运行Plink。 Plink=“C:/Program Files(x86)/Plink/Plink.exe” sPlinkOptions=“-ssh-pw” sCommand=“”&Plink&sPlinkOptions&strPass&&strUser&@&strIP objShell.Exec(sCommand)
我确信我的错误是最后一行了,但我还是有点不确定。实际上,我正在尝试运行一个bat命令,该命令从VBscript接收其变量,并且不希望生成两个单独的文件来执行此操作。

问题在于引号,具体取决于所需的输出。尝试以下方法:

sCommand = """" & Plink & sPlinkOptions & " " & strPass & " " & strUser & "@" & strIP & """"
wscript.echo sCommand

"C:/Program Files (x86)/plink/plink.exe -ssh -pw password username@127.0.0.1"
翻译不喜欢
@
符号周围的引号。
“@”
无效<代码>“@”可以使用。

添加:“WScript.Echo sCommand”(无引号)并注释掉最后一行。这将打印您在控制台中生成的sCommand行,以便您可以查看它-也许这将向您显示错误所在。尝试了一下,错误出现在第13行对sCommand的赋值中,而不是EXECE。这让我看到它报告了正确的信息,但如果我放回objshell.exec(命令)它仍然在第13行第1个字符处出现错误,无法找到文件。