2008年10月2日 星期四

Auto Telnet by WScript

'Get Parameter List
set arg=WScript.Arguments

' Create Script Shell
set sh=WScript.CreateObject("WScript.Shell")

'Run Telnet Command
sh.Run "cmd.exe /c start /realtime telnet xxx.xxx.xxx.xxx "

'Wait Command Running and Response
WScript.Sleep 300
'Input User Name and Password
sh.SendKeys "User Name {ENTER}"
WScript.Sleep 300
sh.SendKeys "Password {ENTER}"
WScript.Sleep 300

'Run your Command
sh.SendKeys "ls -al "+arg.item(0)+" "+arg.item(1)+"{ENTER}"
'Set Sleep time by your Command Running Time
WScript.Sleep 500

'Exit Telnet
sh.SendKeys "exit{ENTER} "
WScript.Sleep 300

'Exit cmd windows
sh.SendKeys "^C"
WScript.Sleep 300

沒有留言:

張貼留言