From: Fox Chang on
Hello All,

If I want to add a filter in below script, when the computer's one of
the DNS IP header is "192.168" ,
change the computer's IP address and DNS IP as below script. If not,
don't change anything.
How can I modify this script?

Thank you.

------------------------------------------------------------------------------------------------------------
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root
\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where
IPEnabled=TRUE")
strIPAddress = Array("192.168.1.141")
strSubnetMask = Array("255.255.255.0")
strGateway = Array("192.168.1.100")
strGatewayMetric = Array(1)
strDNSServerSearchOrder = Array("192.168.10.100","192.168.10.101")
For Each objNetAdapter in colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
errDNSServerSearchOrder =
objNetAdapter.SetDNSServerSearchOrder(strDNSServerSearchOrder)
If errEnable = 0 Then
WScript.Echo "The IP address has been changed."
Else
WScript.Echo "The IP address could not be changed."
End If
Next