打开cmd,然后执行run.bat s 1就会执行tmpsw.vbs的内容,1是作为id传进去的参数。
run.bat:
@echo off
set type=%1
set id=%2
:打开一个telnet
start "%id%" "telnet"
If "%type%" EQU "s" (
@echo "switch"
cscript //nologo tmpsw.vbs %id%
) else (
if "%type%" EQU "r" (
@echo "router"
cscript //nologo tmpr.vbs %id%
) else (
@echo "pc"
cscript //nologo tmp.vbs %id%
)
)
pause
拿某个vbs为例,可以帮我们自动执行一些命令:
tmp.vbs:
Set args = WScript.Arguments
If args.Count = 1 Then
id=WScript.Arguments(0)
End If
port=id+3000
ip=id&".1.202.1"
set sh=WScript.CreateObject("WScript.Shell")
WScript.Sleep 100
sh.SendKeys "o localhost "&port&"{ENTER}"
WScript.Sleep 1000
sh.SendKeys "{ENTER}"
WScript.Sleep 10
sh.SendKeys "no{ENTER}"
WScript.Sleep 10
sh.SendKeys "{ENTER}"
sh.SendKeys "{ENTER}"
sh.SendKeys "en{ENTER}"
sh.SendKeys "{ENTER}"
WScript.Sleep 10
sh.SendKeys "conf t{ENTER}"
WScript.Sleep 10
sh.SendKeys "host SW"&id&"{ENTER}"