WMI IE代理 切换或改变(Use WMI Change IE Proxy)
WMI IE代理 切换或改变(Use WMI Change IE Proxy)
发布时间:2016-12-28 来源:查字典编辑
摘要:将下面的代码,保存为vbs即可复制代码代码如下:IfWScript.Arguments.Count=0ThenGetI=-1ElseGetI...

将下面的代码,保存为 vbs即可

复制代码 代码如下:

If WScript.Arguments.Count = 0 Then

GetI = -1

Else

GetI = CInt(WScript.Arguments(0))

End If

Call YourCode()

'把你弄到的代理都写在一个文本文件里(IP.txt),格式是一行一个: ip:端口

IPS = CreateObject("Scripting.FileSystemObject").OpenTextFile("IP.txt", 1, True).ReadAll

IPS = Split(IPS, vbCrLf)

For IPS_I = 0 To UBound(IPS)

If IPS_I > GetI Then

IPTemp = Split(IPS(IPS_I), ":")

ChangeProxy IPTemp(0), IPTemp(1)

Set WshShell = CreateObject("wscript.shell")

WshShell.run("cscript " & WScript.ScriptFullName & " " & IPS_I)

wscript.quit

End If

Next

Sub YourCode()

'你的代码

End Sub

'使用WMI切换IE代理(Use WMI Change IE Proxy)

Function ChangeProxy(IP, Port)

'获取计算机名

'Set oNetwork = WScript.CreateObject("WScript.Network")

'computername=oNetwork.ComputerName

On Error Resume Next

Set objWMIService = GetObject("winmgmts:.rootCIMV2")

Set objShare = objWMIService.Get("Win32_Proxy.ServerName='computername'")

Set objInParam = objShare.Methods_("SetProxySetting").inParameters.SpawnInstance_()

objInParam.Properties_.Item("ProxyPortNumber") = Port

objInParam.Properties_.Item("ProxyServer") = IP

Set objOutParams = objWMIService.ExecMethod("Win32_Proxy.ServerName='computername'", "SetProxySetting", objInParam)

End Function

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新vbs学习
热门vbs学习
脚本专栏子分类