VBS一键配置VOIP脚本(其中包括VBS操作JS网页中的按钮事件--直接执行确认按钮中的脚本代码)
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> </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网页中的按钮事件--直接执行确认按钮中的脚本代码)的更多相关文章
- Windows Server 2008中使用计划任务定时执行BAT bat进行PHP脚本的执行
Windows Server 2008中使用计划任务定时执行BAT bat进行PHP脚本的执行 2016年01月03日 17:36:00 持之以恒 阅读数:5520 标签: windows定时任务.b ...
- VBS操作JS网页元素实例
'=========================================================================='' VBScript Source File - ...
- 让Jenkins执行GitHub上的pipeline脚本
本文是<Jenkins流水线(pipeline)实战>系列的第二篇,上一篇搭建好了Jenkins环境并执行了一个简单的pipeline任务,当时我们直接在Jenkins网页上编写pipel ...
- WSF脚本详解:组合JS和VBS代码
1.概述 Windows Script Host除了提供一个对象模型之外,还提供了一种脚本框架,这就是WSF脚本.通过WSF约定的标记元素,可以将多种脚本语言写的代码块组合起来,完成任务.除此之外,还 ...
- Windows系统使用vbs脚本或bat脚本强制杀死指定所有进程 vbs实现循环持续写入内容到vbs打开开的记事本 使用vbs、bat添加windows计划任务 使用cmd schtasks命令添加windows计划任务
以下脚本windows7下成功运行过,脚本也可以windows计划任务程序一起组合使用 新建一个记事本文档粘贴下面代码后将新建的记事本文档重命名下面对应的脚本名就能使用了: 添加windows计划任务 ...
- 一键配置网卡IP(win10)脚本
前两天有个小伙伴问我,如何快速配置IP,在公司在家里在宿舍,快速配置IP,然后我特别为这个小伙伴写了一个脚本. @echo off mode con: cols=60 lines=25 title 网 ...
- Centos7一键配置阿里云yum源脚本
Centos7一键配置阿里云yum源脚本 工作中linux系统经常要配置网络yum,故写了一个简单的配置阿里云yum源的的脚本可以单独使用也可以在做自动化部署的时候调用. #!/bin/bash # ...
- CentOS系统优化一键配置脚本
#!/usr/bin/env bash PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export P ...
- shell脚本 阿里云基线检查一键配置
一.简介 源码地址 日期:2017/9/1 介绍:安全加固脚本,会符合阿里云基线检查.有幂等性,可重复执行 效果图: 二.使用 适用:centos6/7 语言:中文 注意:脚本是符合阿里云基线检查的配 ...
随机推荐
- 第九章 观察者模式 OBSERVER
当对象发生改变时,应该使客户得到通知,然后,让客户查询对象的新状态. 其目的是在对象之间(目标对象和客户对象),定义了一个一对多的依赖关系,从而一个对象状态发生改变时,所有依赖这个对象的对象都能得到通 ...
- Python入门学习
1.访问www.python.org/download下载并安装Python3版本 2.命令行输入python启动交互式命令shell,>>>代表当前行用户的输入 3.基本算数运算: ...
- PHP 分析1
D:\wamp64\www\practice test 3: PHP 显示乱码 http://localhost/practice/ex1_5_stu.php <html><meta ...
- Yii 2 修改 URL 模式为 PATH 模式,并隐藏index.php
在弄yii的url重写,希望能把url改成更好记的形式,同时去掉index.php的部分.转化前后的对比:修改前: http://localhost/index.php?r=site/page?vie ...
- C 小问题集锦
摘要:在学习 C 语言编程中遇到的一些容易混淆出错的问题,记录下来备忘. C语言学习 小问题集锦 作者:乌龙哈里 时间:2015-11-24 平台:Window7 64bit,C# :Visual S ...
- pthon之异常、文件练习题
1.在当前目录下查找文件夹“电摄班”,如果不存在则创建2.在电摄班下创建boys.girls.两个txt文件3.将字典中属于电摄班的同学按男女区分,分别放到boys.girls文件中,每个名字在文件中 ...
- 【第五篇】androidEventbus源代码阅读和分析之发送粘性事件和接收粘性事件代码分析
代码里面发送粘性事件代码如下: // 发送Sticky事件 EventBus.getDefault().postSticky(new User("soyoungboy", &quo ...
- LINQ 查询集合总的重复项
select new FMDS_FarmPlotNewInfo { FarmPlo ...
- JS同源策略和跨域问题
同源策略和跨域问题:http://www.cnblogs.com/chaoyuehedy/p/5556557.html 深入浅出JSONP--解决ajax跨域问题:http://www.cnblogs ...
- Eclipse版本区别
各版本的区别: Eclipse IDE for Java Developers 是Eclipse的platform加上JDT插件,用来java开发的 Eclipse IDE for Java EE D ...