切换到电信
Sub Setip(strgw,strgwMetric,strdns)
Set objWMIService = GetObject("winmgmts:\\" & "." & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each objNetAdapter in colNetAdapters
errGateways = objNetAdapter.SetGateways(strgw, strgwmetric)
errSetDNS = objNetAdapter.SetDNSServerSearchOrder(strdns)
If errGateways = 0 Then
Else
WScript.Echo "更改失败,"& errGateways
End If
Next
End Sub
gw="192.168.0.1" '网关
fdns="219.146.0.130" '主dns
sdns="202.102.128.68" '备dns
sgw = Array(gw)
sgwMetric = Array(1)
stdns=Array(fdns,sdns)
myvar=MsgBox("请先确认不在游戏中,否则会造成你的游戏中断!"&vbCrLf&"按确定进行切换,按取消退出", 65, "警告")
if myvar=vbok then
Setip sgw,sgwMetric,stdns
end if
切换到网通
Sub Setip(strgw,strgwMetric,strdns)
Set objWMIService = GetObject("winmgmts:\\" & "." & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each objNetAdapter in colNetAdapters
errGateways = objNetAdapter.SetGateways(strgw, strgwmetric)
errSetDNS = objNetAdapter.SetDNSServerSearchOrder(strdns)
If errGateways = 0 Then
Else
WScript.Echo "更改失败,"& errGateways
End If
Next
End Sub
gw="192.168.0.101" '网关
fdns="202.102.128.68" '主dns
sdns="219.146.0.130" '备dns
sgw = Array(gw)
sgwMetric = Array(1)
stdns=Array(fdns,sdns)
myvar=MsgBox("请先确认不在游戏中,否则会造成你的游戏中断!"&vbCrLf&"按确定进行切换,按取消退出", 65, "警告")
if myvar=vbok then
Setip sgw,sgwMetric,stdns
end if