How to switch or change the WMI IE Agent
This article mainly introduces the relevant knowledge of "how to switch or change WMI IE agent". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to switch or change WMI IE agent" can help you solve the problem.
Just save the following code as vbs
The code is as follows:
If WScript.Arguments.Count = 0 Then
GetI =-1
Else
GetI = CInt (WScript.Arguments (0))
End If
Call YourCode ()
Write all the agents you get in a text file (IP.txt) in the format of one line at a time: 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 agents (Use WMI Change IE Proxy)
Function ChangeProxy (IP, Port)
'get the 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
This is the end of the content about "how to switch or change WMI IE agents". Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.