一、VBS法
1. 建立一个tel.vbs脚本
'建立Shell对象 set sh=WScript.CreateObject("WScript.Shell") WScript.Sleep 1000 '向telnet发送我们平时录入的命令 sh.SendKeys "open 192.168.1.16" WScript.Sleep 1000 sh.SendKeys "{ENTER}" WScript.Sleep 1000 sh.SendKeys "zte{ENTER}" WScript.Sleep 1000 sh.SendKeys "zte{ENTER}" WScript.Sleep 1000 '运行cisco的show run命令 sh.SendKeys "show run{ENTER}"
2. 建立一个batch_tel.bat脚本,用于调用tel.vbs
rem 启动telnet start telnet.exe rem batch telnet cscript //nologo tel.vbs
3. SendKeys命令帮助
对于SendKeys这个命令可以send什么,我们可以看下面的列表: BACKSPACE {BACKSPACE}, {BS}, or {BKSP} BREAK {BREAK} CAPS LOCK {CAPSLOCK} DEL or DELETE {DELETE} or {DEL} DOWN ARROW {DOWN} END {END} ENTER {ENTER}or ~ ESC {ESC} HELP {HELP} HOME {HOME} INS or INSERT {INSERT} or {INS} LEFT ARROW {LEFT} NUM LOCK {NUMLOCK} PAGE DOWN {PGDN} PAGE UP {PGUP} PRINT SCREEN {PRTSC} RIGHT ARROW {RIGHT} SCROLL LOCK {SCROLLLOCK} TAB {TAB} UP ARROW {UP} F1 {F1} F2 {F2} F3 {F3} F4 {F4} F5 {F5} F6 {F6} F7 {F7} F8 {F8} F9 {F9} F10 {F10} F11 {F11} F12 {F12} F13 {F13} F14 {F14} F15 {F15} F16 {F16} SHIFT + CTRL ^ ALT %