生活随笔
收集整理的这篇文章主要介绍了
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 Thenid=WScript.Arguments(0)
End Ifport=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}"
关于SendKeys
总结
以上是生活随笔为你收集整理的BATCH+VBS脚本自动执行命令的全部内容,希望文章能够帮你解决所遇到的问题。
如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。