生活随笔
收集整理的這篇文章主要介紹了
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脚本自动执行命令的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。