以下代码存为.vbs运行
设置IP
strIPAddress=Array("192.168.1.43")
'设置子网掩码
strSubnetMask=Array("255.255.0.0")
'设置网关
DefaultIPGateway=Array("192.168.1.1")
'设置跃点数
GatewayCostMetric=Array("1")
'设置DNS服务器
DNSServer = Array("61.139.44.38", "61.139.2.69")
strComputer="."
Set objWMIService=GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters=objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each objNetAdapter in colNetAdapters
'设置IP和子网掩码
errEnable=objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
'设置网关和跃点数
errEnable=objNetAdapter.SetGateways(DefaultIPGateway,GatewayCostMetric)
'设置DNS
errEnable=objNetAdapter.SetDNSServerSearchOrder(DNSServer)
Next