我对VBS非常陌生,所以希望有人能为我提出一些建议。我正在通过记事本编写VBS脚本,并且我在执行以下操作时遇到了问题:
下面的脚本:
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Exec "app location"
Do Until Success = True
Success = objShell.AppActivate("Application")
Loop
objshell.Sendkeys "{TAB}{TAB}{TAB}{TAB}{TAB}"
objShell.SendKeys "*server name*"
objShell.SendKeys "{enter}"
wscript.sleep 100
strusername=inputbox("Enter your user name","User Name")
If strusername = "" Then
Wscript.Quit
Else
ObjShell.AppActivate("PuTTY Configuration")
objshell.SendKeys "+INS", True
objshell.SendKeys "{enter}"
strpassword=inputbox("Enter your Password","Password")
If strpassword = "" Then
Wscript.Quit
Else
ObjShell.AppActivate("PuTTY Configuration")
objshell.SendKeys "+INS", True
objshell.SendKeys "{enter}"
End if
*Resume the script*
ObjShell.Appactivate("application")
objShell.SendKeys "server name"
objShell.SendKeys "{enter}"
ObjShell.Appactivate("application")
objShell.SendKeys "*I need the password entered earlier to be copied and paste here*"
objShell.SendKeys "{enter}"
wscript.sleep 1000
ObjShell.Appactivate("*application*")
objShell.SendKeys "server name"
objShell.SendKeys "{enter}"
wscript.sleep 6000
and it keeps going until it's finished then does:
ObjShell.Appactivate("*application*")
objShell.SendKeys "exit"
objShell.SendKeys "{enter}"
objShell.SendKeys "exit"
objShell.SendKeys "{enter}"
objShell.SendKeys "exit"
objShell.SendKeys "{enter}"
我也尝试过:
do while not wscript.StdIn.AtEndofLine
input=input & wscript.StdIn.ReadLine
Loop
do while not wscript.StdIn.AtEndofLine
input=input & wscript.StdIn.ReadLine
Loop
wscript.sleep 1000
ObjShell.Appactivate("*application*")
objShell.SendKeys "server name"