strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled = TRUE")
strIPAddress = Array("192.160.1.97")
strSubnetMask = Array("255.255.255.0")
strGateway = Array("192.160.1.1")
strGatewayMetric = Array(1)
Set colNetCards = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objNetCard in colNetCards
arrDNSServers = Array("202.103.96.112")
objNetCard.SetDNSServerSearchOrder(arrDNSServers)
Next
For Each objNetAdapter in colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
If errEnable = 0 Then
WScript.Echo "IP 地址被改变了!"
Else
WScript.Echo "IP 地址不能被改变!"
End If
Next