VBS一鍵配置VOIP腳本代碼
代碼比較長(zhǎng),對(duì)vbs感興趣的朋友可以參考一下
Dim ws,fso,IE Set IE = WScript.createobject("InternetExplorer.Application") Set ws = WScript.CreateObject ("WSCript.shell") Set fso=CreateObject("scripting.filesystemobject") Const reboot="/content.cgi?form=M_SAV" IE.menubar=0 '顯示IE對(duì)象菜單欄 IE.AddressBar=1 '顯示IE對(duì)象地址欄 IE.ToolBar=0 '顯示IE對(duì)象工具欄 IE.StatusBar=1 '不顯示IE對(duì)象狀態(tài)欄 IE.FullScreen=0 '全屏化IE對(duì)象 IE.Height=768 IE.Width=1024 IE.Resizable=1 '設(shè)置IE對(duì)象大小是否可以被改動(dòng) IE.visible=1 '設(shè)置是否可見(jiàn) 'IE.Navigate "192.168.46.3" '==============讀Config配置文件========= filepath=createobject("Scripting.FileSystemObject").GetFile(Wscript.ScriptFullName).ParentFolder.Path file_config=filepath&"\config.ini" Set file=fso.OpenTextFile(file_config,1) '===========取第一行數(shù)據(jù):號(hào)碼============== OneLine=file.ReadLine OneLineStr=Split(OneLine,"=") OneLineCount=UBound(split(OneLine,"=")) 'MsgBox OneLineStr(1) '===============取第二行數(shù)據(jù):密碼=========== TwoLine=file.ReadLine TwoLineStr=Split(TwoLine,"=") TwoLineCount=UBound(split(TwoLine,"=")) 'MsgBox TwoLineStr(1) '===============取第三行數(shù)據(jù):VOIP服務(wù)地址============ ThreeLine=file.ReadLine ThreeLineStr=Split(ThreeLine,"=") ThreeLineCount=UBound(split(ThreeLine,"=")) 'MsgBox ThreeLineStr(1) '===============取第四行數(shù)據(jù):對(duì)講設(shè)備地址============ FourLine=file.ReadLine FourLineStr=Split(FourLine,"=") FourLineCount=UBound(split(FourLine,"=")) 'MsgBox FourLineStr(1) '===============取第五行數(shù)據(jù):瀏覽器安裝目錄============ FiveLine=file.ReadLine FiveLineStr=Split(FiveLine,"=") FiveLineCount=UBound(split(FiveLine,"=")) 'MsgBox FiveLineStr(1) 'MainWeb() Main() '================================================== Function Main() IE.Navigate FourLineStr(1) Do WScript.Sleep 500 Loop Until IE.ReadyState=4 Login() SipSetting() InputParm() VOIP() RebootSys() End Function '====================================================== '登錄系統(tǒng) Function Login() WScript.Sleep 1000 ws.SendKeys "^a" WScript.Sleep 200 ws.SendKeys "admin" ws.SendKeys "{TAB}" ws.SendKeys "^a" WScript.Sleep 200 ws.SendKeys "admin" ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "{ENTER}" End Function '================================================ '進(jìn)入sipsetting菜單 Function SipSetting() If IE.ReadyState=4 Then WScript.Sleep 1000 ws.SendKeys "{TAB 5}" WScript.Sleep 500 ws.SendKeys "{ENTER}" WScript.Sleep 500 ws.SendKeys "{TAB}" WScript.Sleep 500 ws.SendKeys "{ENTER}" WScript.Sleep 2000 Else MsgBox "進(jìn)入配置界面失??!" End If End Function '============================================= '切換輸入界面 Function InputParm() ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "{DOWN}" '選擇開(kāi)啟狀態(tài) WScript.Sleep 300 End Function '========================================= '配置參數(shù) Function VOIP() ws.SendKeys "{TAB}" ws.SendKeys "^a" WScript.Sleep 200 ws.SendKeys OneLineStr(1) 'display name ws.SendKeys "{TAB}" ws.SendKeys "^a" WScript.Sleep 200 ws.SendKeys OneLineStr(1) 'user number ws.SendKeys "{TAB}" ws.SendKeys "^a" WScript.Sleep 200 ws.SendKeys OneLineStr(1) 'auth id ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "^a" WScript.Sleep 200 ws.SendKeys TwoLineStr(1) 'password ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "^a" WScript.Sleep 200 ws.SendKeys ThreeLineStr(1) 'proxy ip ws.SendKeys "{TAB}" 'domain WScript.Sleep 200 ws.SendKeys "^a" WScript.Sleep 200 ws.SendKeys ThreeLineStr(1) '=============保存=========== ws.SendKeys "{TAB 48}" WScript.Sleep 500 ws.SendKeys "{TAB}" WScript.Sleep 500 ws.SendKeys "{ENTER}" WScript.Sleep 1500 End Function '======================================================== '修改參數(shù)后重啟 Function RebootSys() WScript.Sleep 500 ws.SendKeys "{F4}" WScript.Sleep 500 ws.SendKeys "^a" WScript.Sleep 200 ws.SendKeys FourLineStr(1)&reboot WScript.Sleep 500 ' Set test=IE.document.getElementsByTagName ("Button") ws.SendKeys "{ENTER}" WScript.Sleep 2000 Set ALL = Ie.Document.getElementsByTagName("input") '檢測(cè)網(wǎng)頁(yè)元素是否標(biāo)簽為input,且值等于Reboot For Each i In ALL If i.value="Reboot" Then 'i.Click '點(diǎn)擊reboot按鈕 WScript.Sleep 1000 Ie.Document.parentwindow.execScript("top.location='content.cgi?_method_=reboot'") '直接執(zhí)行reboot確認(rèn)操作 Exit For End If Next WScript.Sleep 3000 MsgBox "配置已完成,設(shè)備正在重啟,請(qǐng)耐心等待...",,"提示" If ws.AppActivate("來(lái)自網(wǎng)頁(yè)的消息") Then ws.SendKeys "{ENTER}" WScript.Sleep 2000 MsgBox "配置已完成,設(shè)備正在重啟,請(qǐng)耐心等待...",,"提示" Else 'MsgBox "配置未成功,請(qǐng)重新檢查配置!",,"提示" End If End Function '==================================================================== Function MainWeb() '=============啟動(dòng)地址===================== '方式一:自定義瀏覽器啟動(dòng),需配置路徑 ' Function login() ' ws.run FiveLineStr(1) ' WScript.Sleep 3000 ' ws.SendKeys "{F4}" ' WScript.Sleep 200 ' ws.SendKeys "^a" ' WScript.Sleep 500 ' ws.SendKeys FourLineStr(1) ' WScript.Sleep 500 ' ws.SendKeys "{ENTER}" ' End Function '方式二:用系統(tǒng)默認(rèn)瀏覽器啟動(dòng) ws.Run FourLineStr(1) '===============登錄設(shè)備===================== WScript.Sleep 5000 ws.SendKeys "^a" WScript.Sleep 200 ws.SendKeys "admin" ws.SendKeys "{TAB}" ws.SendKeys "^a" WScript.Sleep 200 ws.SendKeys "admin" ws.SendKeys "{ENTER}" '============進(jìn)入sip setting菜單============= WScript.Sleep 2000 ws.SendKeys "{TAB 5}" WScript.Sleep 500 ws.SendKeys "{ENTER}" WScript.Sleep 500 ws.SendKeys "{TAB}" WScript.Sleep 500 ws.SendKeys "{ENTER}" WScript.Sleep 2000 '==============進(jìn)入編輯狀態(tài)======================= ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "{DOWN}" '選擇開(kāi)啟狀態(tài) WScript.Sleep 300 '==============配置VOIP================ ws.SendKeys "{TAB}" ws.SendKeys "^a" WScript.Sleep 200 ws.SendKeys OneLineStr(1) 'display name ws.SendKeys "{TAB}" ws.SendKeys "^a" WScript.Sleep 200 ws.SendKeys OneLineStr(1) 'user number ws.SendKeys "{TAB}" ws.SendKeys "^a" WScript.Sleep 200 ws.SendKeys OneLineStr(1) 'auth id ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "^a" WScript.Sleep 200 ws.SendKeys TwoLineStr(1) 'password ws.SendKeys "{TAB}" WScript.Sleep 200 ws.SendKeys "^a" WScript.Sleep 200 ws.SendKeys ThreeLineStr(1) 'proxy ip ws.SendKeys "{TAB}" 'domain WScript.Sleep 200 ws.SendKeys "^a" WScript.Sleep 200 ws.SendKeys ThreeLineStr(1) '=============保存=========== ws.SendKeys "{TAB 48}" WScript.Sleep 500 ws.SendKeys "{TAB}" WScript.Sleep 500 ws.SendKeys "{ENTER}" WScript.Sleep 1500 '===============重啟========== ws.SendKeys "{TAB 18}" WScript.Sleep 1000 ws.SendKeys "{ENTER}" WScript.Sleep 1000 ws.SendKeys "{TAB 2}" WScript.Sleep 500 ws.SendKeys "{ENTER}" WScript.Sleep 1000 If ws.AppActivate("來(lái)自網(wǎng)頁(yè)的消息") Then ws.SendKeys "{ENTER}" WScript.Sleep 1000 MsgBox "配置已完成,設(shè)備正在重啟,請(qǐng)耐心等待...",,"提示" Else MsgBox "配置未成功,請(qǐng)重新檢查配置!",,"提示" End If End Function Set ws=Nothing Set IE=Nothing Set fso=Nothing
網(wǎng)頁(yè)部分JS代碼:
<div id="content" width="650">
<form name="M_SAV" method="GET" enctype="multipart/form-data" onReset="" action="content.cgi">
<input type=HIDDEN name="_method_" value="apply">
<input type=HIDDEN name="form" value="M_SAV">
<input type=HIDDEN name="commit" value="0">
<table id="cFORM" width="650" border="0" cellspacing="0" cellpadding="0" >
<tr><td> </td></tr>
</table><table width="500"><td align="center">
<input type=BUTTON onclick="javascript:if ( confirm('Reboot') ) top.location='content.cgi?_method_=reboot';" target="_top" value="Reboot"></a>
</td></table></form>
這篇文章就介紹到這了,希望大家以后多多支持我們。
上一篇:vbs實(shí)現(xiàn)的tasklist效果代碼
欄 目:vb
下一篇:vbs 自制數(shù)字益智游戲?qū)崿F(xiàn)代碼
本文標(biāo)題:VBS一鍵配置VOIP腳本代碼
本文地址:http://mengdiqiu.com.cn/a1/vb/7096.html
您可能感興趣的文章
- 01-10下載文件到本地運(yùn)行的vbs
- 01-10VBS中的正則表達(dá)式的用法大全 <font color=red>原創(chuàng)&
- 01-10VBS中SendKeys的基本應(yīng)用
- 01-10VBScript教程 第十一課深入VBScript
- 01-10用VBSCRIPT控制ONSUBMIT事件
- 01-10VBScript語(yǔ)法速查及實(shí)例說(shuō)明
- 01-10VBS中Select CASE的其它用法
- 01-10VBScript教程 第七課使用條件語(yǔ)句
- 01-10vbscript 可以按引用傳遞參數(shù)嗎?
- 01-10VBScript教程 第二課在HTML頁(yè)面中添加VBscript代碼


閱讀排行
- 1C語(yǔ)言 while語(yǔ)句的用法詳解
- 2java 實(shí)現(xiàn)簡(jiǎn)單圣誕樹(shù)的示例代碼(圣誕
- 3利用C語(yǔ)言實(shí)現(xiàn)“百馬百擔(dān)”問(wèn)題方法
- 4C語(yǔ)言中計(jì)算正弦的相關(guān)函數(shù)總結(jié)
- 5c語(yǔ)言計(jì)算三角形面積代碼
- 6什么是 WSH(腳本宿主)的詳細(xì)解釋
- 7C++ 中隨機(jī)函數(shù)random函數(shù)的使用方法
- 8正則表達(dá)式匹配各種特殊字符
- 9C語(yǔ)言十進(jìn)制轉(zhuǎn)二進(jìn)制代碼實(shí)例
- 10C語(yǔ)言查找數(shù)組里數(shù)字重復(fù)次數(shù)的方法
本欄相關(guān)
- 01-10下載文件到本地運(yùn)行的vbs
- 01-10飄葉千夫指源代碼,又稱qq刷屏器
- 01-10SendKeys參考文檔
- 01-10什么是一個(gè)高效的軟件
- 01-10VBS中的正則表達(dá)式的用法大全 &l
- 01-10exe2swf 工具(Adodb.Stream版)
- 01-10VBS中SendKeys的基本應(yīng)用
- 01-10用VBSCRIPT控制ONSUBMIT事件
- 01-10VBScript教程 第十一課深入VBScript
- 01-10VBScript語(yǔ)法速查及實(shí)例說(shuō)明
隨機(jī)閱讀
- 01-11ajax實(shí)現(xiàn)頁(yè)面的局部加載
- 08-05DEDE織夢(mèng)data目錄下的sessions文件夾有什
- 01-10C#中split用法實(shí)例總結(jié)
- 08-05織夢(mèng)dedecms什么時(shí)候用欄目交叉功能?
- 01-10使用C語(yǔ)言求解撲克牌的順子及n個(gè)骰子
- 01-10SublimeText編譯C開(kāi)發(fā)環(huán)境設(shè)置
- 01-10delphi制作wav文件的方法
- 01-11Mac OSX 打開(kāi)原生自帶讀寫(xiě)NTFS功能(圖文
- 08-05dedecms(織夢(mèng))副欄目數(shù)量限制代碼修改
- 04-02jquery與jsp,用jquery