- Sub Main
- Const ForReading = 1
- Const ForWriting = 2
- Const ForAppending = 8
-
- Dim arrcmd,Element,waitStrs,result,fso,tsr,commandsFile,waitStr
- xsh.Screen.Synchronous = true
- commandsFile = "C:\Users\flashercs\Documents\NetSarang Computer\7\Xshell\Scripts\commands.txt" '命令列表文件
- waitStr = "username@hostname" 'waitfor text, ex: root@localhost
- Set fso = CreateObject("Scripting.FileSystemObject")
- Set tsr = fso.OpenTextFile(commandsFile,ForReading,False,vbUseDefault)
- Do Until tsr.AtEndOfStream
- xsh.Screen.Send tsr.ReadLine
- xsh.Screen.Send vbCr
- xsh.Screen.WaitForString waitStr
- Loop
- Set tsr = Nothing
- Set fso = Nothing
- xsh.Screen.Synchronous = false
-
- End Sub
复制代码 保存为vbs脚本.登陆后打开菜单 工具>脚本>运行,选择脚本运行.
命令列表放到一个commands.txt中. |