制作线路切换器!

 
 
新建一个文本文件后缀名为(.vbs)(把下代码复制到文本文件里面其它的不要)(红色字体为注释)
注:保存时记得把红色字体删除
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each objNetAdapter in colNetAdapters
sip=objNetAdapter.IPAddress
strIPAddress = sip
strSubnetMask = Array("填写子网掩码")
strGateway = Array("填写网关地址")
strGatewayMetric = Array(1)
strDNS = Array("此处填写DNS", "此处填写DNS")      'DNS  (网通的填写网通DNS,电信的填写电信的DNS)
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
errDNS = objNetAdapter.SetDNSServerSearchOrder(strDNS)
'输出开始
If errEnable = 0 and errGateways = 0 and errDNS = 0 Then
     WScript.Echo "更改成电信(网通的请把电信2字改成网通)线路!"
Else
     WScript.Echo "更改失败,请与管理员联系!"
End If
'输出结束
exit for        '只修改第一个网卡的设置
Next

你可能感兴趣的:(职场,休闲,线路,切换器)