Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vbs script to change all IP address via DNS name

Status
Not open for further replies.

unclegimoah

Programmer
Oct 25, 2007
3
GB
Hi Guys,

I have not used vb script for many years, we have just been taken over by a global company and we have to change all ip addresses, subnet, gateway and PDNS IP. I have a script to change the local ip settings, is it possible to change this script so that if I have a text file will IP and DNS names I can run a vbscript and it will change all ips. Please help.:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & 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)

For Each objNetAdapter in colNetAdapters
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
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top