BATCH+VBS脚本自动执行命令
Posted flipped
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了BATCH+VBS脚本自动执行命令相关的知识,希望对你有一定的参考价值。
打开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}"
以上是关于BATCH+VBS脚本自动执行命令的主要内容,如果未能解决你的问题,请参考以下文章