欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

WMI IE代理 切换或改变(Use WMI Change IE Proxy)

程序员文章站 2022-08-27 15:17:08
将下面的代码,保存为 vbs即可复制代码 代码如下:if wscript.arguments.count = 0 then geti = -1 else geti = ci...
将下面的代码,保存为 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:\\.\root\cimv2")
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