我正在尝试编写一个VBScript来登录PUTTY并执行一堆命令。我试图从输入框中取出用户ID和密码进行登录,然后将其作为登录变量传递。
但我无法正确传递UserName
和Passwrd
。请建议。
Dim UserName
Dim Passwrd
UserName = InputBox("Please Enter Your UserID:")
Passwrd = InputBox("Please Enter Your Password:")
Set shell = WScript.CreateObject("WScript.Shell")
pcmd = "putty.exe -ssh UserName@10.177.104.109 -pw Passwrd"
Set exec = shell.Exec(pcmd)
Set pout = exec.StdOut
答案 0 :(得分:1)
您需要使用字符串连接(&
)将变量值与字符串文字组合:
pcmd = "putty.exe -ssh " & UserName & "@10.177.104.109 -pw " & Passwrd