strComputer="."
Set objWMIService=GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters=objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where settingid='{E48F71A7-9AD4-4CD0-9ED9-A7BFD79AA056}'") '前面的一长串为网卡的名称,需要根据实际情况修改
strIP=Array("1.1.1.6")
strMask=Array("255.255.255.0")
dns=Array("1.1.1.200","1.1.1.201")
arrGateways=Array("1.1.1.1")
arrGatewayCostMetrics=Array(1)
For each objNetAdapter in colNetAdapters
errEnable=objNetAdapter.EnableStatic (strIP,strMask)
errEnable=objNetAdapter.SetDNSServerSearchOrder (dns)
errEnable=objNetAdapter.SetGateways (arrGateways,arrGatewayCostMetrics)
Next
转载于:https://www.cnblogs.com/jerry1999/archive/2013/02/24/3677348.html