windows自動登入telnet批處理檔案VBS法(Windows Script Host)

edwardking888發表於2010-11-09
Windows平臺:
複製一下程式碼到記事本中並另儲存為autoTelnet.bat,之後雙擊執行就實現自動登入到telnet伺服器了,伺服器IP自己修改
@echo off
echo set sh=WScript.CreateObject("WScript.Shell") >telnet_tmp.vbs
echo WScript.Sleep 300 >>telnet_tmp.vbs
echo sh.SendKeys "open 192.168.1.200" >>telnet_tmp.vbs
echo WScript.Sleep 300 >>telnet_tmp.vbs
echo sh.SendKeys "{ENTER}" >>telnet_tmp.vbs
echo WScript.Sleep 300 >>telnet_tmp.vbs
echo sh.SendKeys "登入賬號{ENTER}" >>telnet_tmp.vbs
echo WScript.Sleep 300 >>telnet_tmp.vbs
echo sh.SendKeys "登入密碼{ENTER}">>telnet_tmp.vbs
start telnet
cscript. //nologo telnet_tmp.vbs
del telnet_tmp.vbs

附錄:

對於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 %

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8183550/viewspace-677755/,如需轉載,請註明出處,否則將追究法律責任。

相關文章