服务器之家

服务器之家 > 正文

VBS一键配置VOIP脚本代码

时间:2020-08-19 10:50     来源/作者:VBS脚本之家

代码比较长,对vbs感兴趣的朋友可以参考一下

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
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>

这篇文章就介绍到这了,希望大家以后多多支持服务器之家。

原文链接:https://www.cnblogs.com/jinjiangongzuoshi/p/3914295.html

标签:

相关文章

热门资讯

2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全
2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全 2019-12-26
歪歪漫画vip账号共享2020_yy漫画免费账号密码共享
歪歪漫画vip账号共享2020_yy漫画免费账号密码共享 2020-04-07
Intellij idea2020永久破解,亲测可用!!!
Intellij idea2020永久破解,亲测可用!!! 2020-07-29
最新idea2020注册码永久激活(激活到2100年)
最新idea2020注册码永久激活(激活到2100年) 2020-07-29
男生常说24816是什么意思?女生说13579是什么意思?
男生常说24816是什么意思?女生说13579是什么意思? 2019-09-17
返回顶部