레이블이 자동로그인인 게시물을 표시합니다. 모든 게시물 표시
레이블이 자동로그인인 게시물을 표시합니다. 모든 게시물 표시

2013년 1월 29일 화요일

윈도우 telnet 자동 로그인

윈도우에서 telnet 자동 접속 후 명령어 실행하는 프로그램입니다.

확장자는 .vbs 로 합니다.

사용법

1. C:\oneIP.txt 파일을 만들고 한줄씩 접속할  아이피를 넣어준다.

2.아래 소스를 아무이름으로 .vbs 확장자로 만든다.

ex)telnet_auto.vbs

3. 실행한다.

ps. 접속 후 실행할 명령은 알아서 넣기.


set WshShell = WScript.CreateObject("WScript.Shell")
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Const ipListFile = "C:\oneIP.txt"
Set Shell = CreateObject("WScript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")

If FSO.FileExists(ipListFile) Then
Set SwitchIP = FSO.opentextfile(ipListFile, ForReading, False)
Else
Wscript.Echo "This file (" + ipListFile + ") does not exist."
Wscript.Quit
End If
Dim userId
Dim userPw

userId = "yourid"
userPw = "yourpass"

WScript.Echo "Don't touch Anything!!"

While Not SwitchIP.atEndOfStream
IP = SwitchIP.Readline()
WshShell.Run "cmd"
WScript.Sleep 100
WshShell.AppActivate "C:\Windows\system32\cmd.exe"

WScript.Sleep 100
rem telnet [address] [port]
WshShell.SendKeys "telnet " + IP + " 23{ENTER}"

WScript.Sleep 2000
rem [id]
WshShell.SendKeys userId + "{ENTER}"

WScript.Sleep 2000
rem [pwd]
WshShell.SendKeys userPw + "{ENTER}"

WScript.Sleep 1000
rem [command what you want]
WshShell.SendKeys "show ver{ENTER}"

WshShell.SendKeys "{ENTER}"
WScript.Sleep 2000
WshShell.SendKeys "exit{ENTER}"

Wend
WScript.Sleep 2000
WScript.Echo "Completed."