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>

VBS一键配置VOIP脚本(其中包括VBS操作JS网页中的按钮事件--直接执行确认按钮中的脚本代码)的更多相关文章

  1. Windows Server 2008中使用计划任务定时执行BAT bat进行PHP脚本的执行

    Windows Server 2008中使用计划任务定时执行BAT bat进行PHP脚本的执行 2016年01月03日 17:36:00 持之以恒 阅读数:5520 标签: windows定时任务.b ...

  2. VBS操作JS网页元素实例

    '=========================================================================='' VBScript Source File - ...

  3. 让Jenkins执行GitHub上的pipeline脚本

    本文是<Jenkins流水线(pipeline)实战>系列的第二篇,上一篇搭建好了Jenkins环境并执行了一个简单的pipeline任务,当时我们直接在Jenkins网页上编写pipel ...

  4. WSF脚本详解:组合JS和VBS代码

    1.概述 Windows Script Host除了提供一个对象模型之外,还提供了一种脚本框架,这就是WSF脚本.通过WSF约定的标记元素,可以将多种脚本语言写的代码块组合起来,完成任务.除此之外,还 ...

  5. Windows系统使用vbs脚本或bat脚本强制杀死指定所有进程 vbs实现循环持续写入内容到vbs打开开的记事本 使用vbs、bat添加windows计划任务 使用cmd schtasks命令添加windows计划任务

    以下脚本windows7下成功运行过,脚本也可以windows计划任务程序一起组合使用 新建一个记事本文档粘贴下面代码后将新建的记事本文档重命名下面对应的脚本名就能使用了: 添加windows计划任务 ...

  6. 一键配置网卡IP(win10)脚本

    前两天有个小伙伴问我,如何快速配置IP,在公司在家里在宿舍,快速配置IP,然后我特别为这个小伙伴写了一个脚本. @echo off mode con: cols=60 lines=25 title 网 ...

  7. Centos7一键配置阿里云yum源脚本

    Centos7一键配置阿里云yum源脚本 工作中linux系统经常要配置网络yum,故写了一个简单的配置阿里云yum源的的脚本可以单独使用也可以在做自动化部署的时候调用. #!/bin/bash # ...

  8. CentOS系统优化一键配置脚本

    #!/usr/bin/env bash PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export P ...

  9. shell脚本 阿里云基线检查一键配置

    一.简介 源码地址 日期:2017/9/1 介绍:安全加固脚本,会符合阿里云基线检查.有幂等性,可重复执行 效果图: 二.使用 适用:centos6/7 语言:中文 注意:脚本是符合阿里云基线检查的配 ...

随机推荐

  1. JS禁用右键,禁用打印,防止另存为,IE浏览器识别(转载)

    oncontextmenu="window.event.returnValue=false" style="overflow-y: hidden; overflow-x: ...

  2. redis8--数据持久化两种方式

    持久化功能redis为了内部数据的安全考虑,会把本身的数据以文件形式保存到硬盘中一份,在服务器重启之后会把硬盘中的数据恢复到内存(redis)的里边.数据保存到硬盘的过程就称为"持久化&qu ...

  3. 去除右键的opendgl

    Windows Registry Editor Version 5.00[-HKEY_CLASSES_ROOT\Unknown\shell\opendlg][-HKEY_CLASSES_ROOT\Un ...

  4. NewtonJson中转义的斜杠\和多余的引号处理

    使用newtonjson序列化的json串正常的,但通过网络传输后,会再包装一层引号和对原有定义引号的转义,最后结果就变成这种数据: “\"{\\\"State\":fa ...

  5. TortoiseGit 错误信息Aborting commit due to empty commit message.解决

    错误信息: Aborting commit due to empty commit message. git不能完全退出(退出码 1) (47 ms @ 2016/2/19 14:03:24) 解决办 ...

  6. L2-001. 紧急救援

    L2-001. 紧急救援 题目链接:https://www.patest.cn/contests/gplt/L2-001 Dijstra 本题是dijstra的拓展,在求最短路的同时,增加了不同的最短 ...

  7. hashmap冲突的解决方法以及原理分析:

    在Java编程语言中,最基本的结构就是两种,一种是数组,一种是模拟指针(引用),所有的数据结构都可以用这两个基本结构构造,HashMap也一样.当程序试图将多个 key-value 放入 HashMa ...

  8. 关于odbc连接orcal,用户名密码大小写敏感问题

    在oracle的之前版本时, 你的用户名密码是大小写不敏感的, 但在11g中, 数据库默认密码的大小写是敏感的, 于是我们就知道了一个事实, 那就是jdbc在给oracle密码时, 会将其变成大写,真 ...

  9. 2016年团体程序设计天梯赛-决赛 L1-1. 正整数A+B(15)

    本题的目标很简单,就是求两个正整数A和B的和,其中A和B都在区间[1,1000].稍微有点麻烦的是,输入并不保证是两个正整数. 输入格式: 输入在一行给出A和B,其间以空格分开.问题是A和B不一定是满 ...

  10. 用block解决nstimer循环引用

    大多数开发者可能都会这样来实现定时器.创建定时器的时候,由于目标对象是self,所以要保留此实例.然而,因为定时器是用实例变量存放的,所以实例也保留了定时器,这就造成了循环引用.除非调用stop方法, ...