For network administrators, managing dozens or hundreds of hosts, routers, switches, and other things by one person is also common. How can we manage them? This requires Batch. Now we will introduce the Batch telnet settings. I believe it will be useful for administrators.
Generally, there are two methods:
1. Windows Script Host using VBS)
2. Automatic Terminal Method for some terminals that can be configured with automatic telnet)
Here we will discuss the first method: The VBS method. Because the Windows Script Host is provided by the system, we can do it without installing local software. Therefore, it is generally the first choice to solve the problem.
First, we create a script named tel. vbs. Here we use Batch to telnet to the cisco router as an example. You can modify the relevant content.
- 'Create Shell object
-
- Set sh = WScript. CreateObject ("WScript. Shell ")
- WScript. Sleep 1000
- 'Send the commands we input to telnet
- Sh. SendKeys "open 192.168.1.1"
- WScript. Sleep 1000
- Sh. SendKeys "{ENTER }"
- WScript. Sleep 1000
- Sh. SendKeys "password {ENTER }"
- WScript. Sleep 1000
- Sh. SendKeys "en {ENTER }"
- WScript. Sleep 1000
- Sh. SendKeys "passord {ENTER }"
- WScript. Sleep 1000
- 'Run the cisco show run Command
- Sh. SendKeys "show run {ENTER }"
Then, create a batch_tel.bat batch file:
- Rem start telnet
- Start telnet.exe
- Rem batch telnet
- Cscript // nologo tel. vbs
Finally, we only need to run batch_tel.bat to easily handle the Batch telnet operation.
For what the SendKeys command can send, we can look at the following list:
- 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 %