VBS一键配置VOIP脚本代码

代码比较长,对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对象菜单栏
IE.AddressBar=1 '显示IE对象地址栏
IE.ToolBar=0 '显示IE对象工具栏
IE.StatusBar=1 '不显示IE对象状态栏
IE.FullScreen=0 '全屏化IE对象
IE.Height=768
IE.Width=1024
IE.Resizable=1 '设置IE对象大小是否可以被改动
IE.visible=1 '设置是否可见 

'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)
    
'===========取第一行数据:号码==============
OneLine=file.ReadLine
OneLineStr=Split(OneLine,"=")
OneLineCount=UBound(split(OneLine,"="))
'MsgBox OneLineStr(1)                   

    
'===============取第二行数据:密码===========
TwoLine=file.ReadLine
TwoLineStr=Split(TwoLine,"=")
TwoLineCount=UBound(split(TwoLine,"="))
'MsgBox TwoLineStr(1)
    
'===============取第三行数据:VOIP服务地址============
ThreeLine=file.ReadLine
ThreeLineStr=Split(ThreeLine,"=")
ThreeLineCount=UBound(split(ThreeLine,"="))
'MsgBox ThreeLineStr(1)
    
'===============取第四行数据:对讲设备地址============
FourLine=file.ReadLine
FourLineStr=Split(FourLine,"=")
FourLineCount=UBound(split(FourLine,"="))
'MsgBox FourLineStr(1)
    
'===============取第五行数据:浏览器安装目录============
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 
'======================================================
'登录系统
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 
'================================================
'进入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 "进入配置界面失败!"
     
    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}"  '选择开启状态
    WScript.Sleep 300

End Function 
'=========================================
'配置参数
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 

'========================================================
'修改参数后重启
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")  '检测网页元素是否标签为input,且值等于Reboot

    For Each i In ALL

    If i.value="Reboot" Then

       'i.Click  '点击reboot按钮
       
        WScript.Sleep 1000
       
        Ie.Document.parentwindow.execScript("top.location='content.cgi?_method_=reboot'")  '直接执行reboot确认操作

        Exit For

     
    End If

    Next
    
    WScript.Sleep 3000    
    
    MsgBox "配置已完成,设备正在重启,请耐心等待...",,"提示"

    If ws.AppActivate("来自网页的消息") Then 
    
    
        ws.SendKeys "{ENTER}"
        WScript.Sleep 2000
        
        MsgBox "配置已完成,设备正在重启,请耐心等待...",,"提示"
        
    Else 
        'MsgBox "配置未成功,请重新检查配置!",,"提示"
        
    End If 

End Function 

'====================================================================

Function MainWeb()

    '=============启动地址=====================
'方式一:自定义浏览器启动,需配置路径
'   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    

'方式二:用系统默认浏览器启动 
    ws.Run FourLineStr(1)

    '===============登录设备=====================
    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}"
    
    '============进入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
    
    
    '==============进入编辑状态=======================
    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}"  '选择开启状态
    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("来自网页的消息") Then 
    
        ws.SendKeys "{ENTER}"
        WScript.Sleep 1000
        
        MsgBox "配置已完成,设备正在重启,请耐心等待...",,"提示"
        
    Else 
        MsgBox "配置未成功,请重新检查配置!",,"提示"
        
    End If 

End Function 

Set ws=Nothing 
Set IE=Nothing 
Set fso=Nothing 

网页部分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>&nbsp</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>

这篇文章就介绍到这了,希望大家以后多多支持我们。

(0)

相关推荐

  • VBS一键配置VOIP脚本代码

    代码比较长,对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

  • 一键配置本地yum源的shell脚本

    效果如图: 代码 #!/bin/bash #Author:GaoHongYu #QQ:1061767621 #Time:2019-12-26 16:30:19 #Name:yumgz.sh #Version:V1.0 CKGZ=$( df -Th | grep -o "iso9660" ) KJGZ=$( cat /etc/fstab | grep -o "iso9660" ) read -p "欢迎使用Yum自动挂载脚本,y开始|n退出: "

  • 教你bat脚本一键配置java开发环境

    背景 在新电脑配置或者新人入职时需要对java开发相关环境进行配置安装,但时常会因为安装配置不到位或者操作错误导致时间的浪费,所以在空余时间收集了一系列软件的免安装版本,并且编写了相关配置脚本,让环境安装变得标准化. 概览 安装包目录如下如所示 BaseEnv包含jdk(1.8),maven(3.2.5) ProgramEnv包含idea(2019.2) SoftEnv包含mysql(5.7),navicat(15),redis,redismanage(1.5.8) remark为安装总说明 s

  • 两个批量挂马vbs脚本代码

    scan.vbe cscript scan.vbe web目录 程序代码: '版权信息 br="************************************" & vbCrLf br=br & "* VBS 批量挂马脚本 *" & vbCrLf br=br & "* BY BanLG *" & vbCrLf br=br & "**************************

  • 一键配置jdk环境变量的批处理代码

    第一步:肯定是下载JDK并且安装好,记住路径 创建java环境变量批处理cheng步骤: 1.新建txt文本后选择编辑. 2.输入如下代码 @echo off echo 正在设置Java环境变量 pause wmic ENVIRONMENT create name="JAVA_HOME",username="<system>",VariableValue="C:\Program Files (x86)\Java\jdk1.7.0_79"

  • shell脚本一键同时推送代码至github和gitee的解决办法

    自己写的东西,要同时推送多个git地址,解决办法如下: 1.先要初始化你的git              进入自己的项目目录,然后执行 git  init cd /app/code/go-study git init 2.执行以下脚本: #!/bin/bash #author Oliver #since 2020-09-03 15:24:31 git remote rm origin #replace your git location git remote add origin 'https

  • Android与iOS包体优化及一键自动打包脚本

    目录 系统信息 介绍 安卓APK优化包体大小 一.原理与介绍 二.Flutter代码配置 三.Android代码配置 四.多渠道调试与打包指令 安卓一键打包脚本 一.简单介绍 二.项目路径结构 三.脚本内容 四.脚本使用步骤 苹果优化包体大小 一.常规优化(分发到 App Store 或者 打Ad hoc 测试包) 二.非常规优化 1.Flutter导出IPA(共4步) 2.第一次优化包体大小(共5步) 3.第二次优化包体大小(共6步) 4.一些说明 苹果一键打包脚本 一.简单介绍 二.项目路径

  • 如何让动态插入的javascript脚本代码跑起来。

    首先,声明方法很多种,直接间接的方法都有,只罗列一般情况下的两种模式: 假设我们要装入的代码是a.js: var foo=function(){ document.write("I am a.js content foo() function by never-online"); }; 一.直接插入src,这种方法简单而直接,但有局限性, 1) <script> var x=document.createElement("SCRIPT"); x.src=

  • 简陋的swift carthage copy-frameworks 辅助脚本代码

    在看 carthage 时,其中需要配置一个 copy-frameworks 脚本,此脚本特殊的地方,需要手动填写 Input Files 和 Output Files.一个一个填写,很糟心~ 观察了下,对应修改的是 xxx.xcodeproj/project.pbxproj 中这个文本文件的特定位置的字段,类似于: /* Begin PBXShellScriptBuildPhase section */ 750D68EC2000817C006235CD /* ShellScript */ =

  • jenkins配置python脚本定时任务过程图解

    这篇文章主要介绍了jekins配置python脚本定时任务过程图解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 1.首先安装jekins环境,访问网页https://jenkins.io/zh/download/,下载长期稳定版如下: 2.下载安装包后直接运行,进行选择安装路径,傻瓜式安装.安装完成后,点Finished,弹出jekins输入密匙网页,根据网页提示路径,找到 对应的jekins密匙输入后,选择推荐插件安装即可.(也可以不安装插

随机推荐