Hi There
Change the IP details and Computer name to suit
The Computer name currently has a . in it which means local machine. Its worth leaving this to test on your local PC first, then change after.
BTW, Keep all the quotes when changing the details.
Hope it helps
' Specidfy the computerName (. means local)
strComputer = "."
' Bind to the computers WMI
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
' Bind to the network card that has IP enabled
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
' Set our IP Details etc.
strIPAddress = Array("192.168.1.141")
strSubnetMask = Array("255.255.255.0")
strGateway = Array("192.168.1.1")
strGatewayMetric = Array(1)
arrDNSServers = Array("192.168.1.100", "192.168.1.200")
' or use this if only 1 DNS server
' arrDNSServers = Array("192.168.1.100")
' Loop the properties of the network adapter and make the changes
For Each objNetAdapter in colNetAdapters
' Set IP, Subnet and gateway
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
If errEnable = 0 Then
WScript.Echo "The IP address has been changed."
Else
WScript.Echo "The IP address could not be changed."
End If
' Set the DNS Domain
errDNSname = objNetAdapter.SetDNSDomain("fabrikam.com")
If errDNSname = 0 Then
WScript.Echo "The DNS name has been changed."
Else
WScript.Echo "The DNS name could not be changed."
End If
' Set the DNS Servers
errDNSservers = objNetAdapter.SetDNSServerSearchOrder(arrDNSServers)
If errDNSservers = 0 Then
WScript.Echo "The DNS server has been changed."
Else
WScript.Echo "The DNS server could not be changed."
End If
Next
Regards
Krystian