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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

scripting tcp/ip settings

Status
Not open for further replies.

ulio

IS-IT--Management
Oct 2, 2003
28
0
0
US
Hey all,

I was wondering if anyone could lead me in the right direction in creating a script to automatically set a computer's dns server and suffix search order settings within tcp/ip properties....i swear i've seen this done before. if anyone know of any sites or perhaps has code samples, i'd appreciate big time

thanks

-ulio
 
Something like this?

Code:
For Each objNetAdapter in colNetAdapters
    errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
    errGateways = objNetAdapter.SetGateways(strGateway)
    errDNSServers = objNetAdapter.SetDNSServerSearchOrder(strDNSServers)
    If errEnable = 0 Then
        WScript.Echo "Static IP addressing now configured."
    Else
        WScript.Echo "Static IP addressing could not be configured."
    End If
Next

Just fill in the variables with the addresses

Spong
 
I should have added this at the beginning... it would be useful!

Code:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
    ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")

Spong
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top