网吧电信网通转换代码 切换到电信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 NextEnd Sub gw="192.168.0.1" '网关fdns="219.146.0.130" '主dnssdns="202.102.128.68" '备dns sgw = Array(gw)sgwMetric = Array(1)stdns=Array(fdns,sdns) myvar=MsgBox("请先确认不在游戏中,否则会造成你的游戏中断!"&vbCrLf&"按确定进行切换,按取消退出", 65, "警告")if myvar=vbok thenSetip sgw,sgwMetric,stdnsend 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 NextEnd Sub gw="192.168.0.101" '网关fdns="202.102.128.68" '主dnssdns="219.146.0.130" '备dns sgw = Array(gw)sgwMetric = Array(1)stdns=Array(fdns,sdns) myvar=MsgBox("请先确认不在游戏中,否则会造成你的游戏中断!"&vbCrLf&"按确定进行切换,按取消退出", 65, "警告")if myvar=vbok thenSetip sgw,sgwMetric,stdnsend if

评论