WMI IE Agent switching or changing (use WMI change IE proxy) _vbs

Source: Internet
Author: User
Save the following code as a VBS
Copy Code code as follows:

If WScript.Arguments.Count = 0 Then
Geti =-1
Else
Geti = CInt (wscript.arguments (0))
End If

Call Yourcode ()


' Write your agent in a text file (IP.txt), one line: IP: Port
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 ()
' Your code
End Sub

' Use WMI to switch IE proxy (using WMI change IE proxy)

Function Changeproxy (IP, Port)
' Get computer name
' 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.