Vbscript 如何将Wshshell.sendkeys的结果保存到文本文件中?
我根本不是一个程序员,只是想为Windows平台上的日常网络管理任务编写一个WSH脚本。我的脚本如下:Vbscript 如何将Wshshell.sendkeys的结果保存到文本文件中?,vbscript,wsh,Vbscript,Wsh,我根本不是一个程序员,只是想为Windows平台上的日常网络管理任务编写一个WSH脚本。我的脚本如下: Option Explicit Dim WshShell Dim objFSO Dim objFile Dim strRhost Set WshShell = CreateObject("WScript.Shell") Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextF
Option Explicit
Dim WshShell
Dim objFSO
Dim objFile
Dim strRhost
Set WshShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("c:\test\swlist.txt", 1)
Do Until objFile.AtEndOfStream
strRhost = objFile.ReadLine
WshShell.Run "putty.exe -ssh " & Chr(34) & strRhost & Chr(34) & " -l admin -pw admin")
WScript.Sleep 3000
WshShell.SendKeys "enable{ENTER}"
WScript.Sleep 100
WshShell.SendKeys "password{ENTER}"
WScript.Sleep 1000
WshShell.SendKeys ("show clock{Enter}")
WScript.Sleep 1500
WshShell.SendKeys ("show version{Enter}")
WScript.Sleep 1500
WshShell.SendKeys ("show run{Enter}")
WScript.Sleep 1500
WshShell.SendKeys "exit{ENTER}"
WScript.Sleep 1000
WshShell.SendKeys "exit{ENTER}"
Loop
objFile.Close
WScript.Quit
上面的脚本工作正常,但如何将所有结果的结果输出到屏幕和文本文件?研究如何使用
plink
而不是putty
thks Dave,但是1。Plink无法将所有结果完全传输到目标(我已测试)。2.Plink有时在运行多个命令时挂断(有时意外退出设备)。