IP Config Script

Status
Not open for further replies.

Zindel

Baseband Member
Messages
92
so i am trying to make a script that changes an IP address config for a windows XP computer. so far i have found a working script that does just what i need it to, however i need to find out how to add the DNS servers to it.

Code:
strComputer = "."
strConnection = "Local Area Connection"
strIP = Array("0.0.0.0")
strMask = Array("255.255.255.0")
strGatewayIP = Array("0.0.0.0")
' ------ END CONFIGURATION ---------
set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set colNA = objWMI.ExecQuery("select * " & _
                            " from Win32_NetworkAdapter " & _
                            " where NetConnectionID = '" & strConnection & "'" ) 
for each objNA in colNA
   set colNAConfig = objWMI.ExecQuery _
      ("ASSOCIATORS OF {Win32_NetworkAdapter.DeviceID='" & _
        objNA.DeviceID & "'} " & _
      " WHERE resultClass = win32_NetworkAdapterConfiguration ")
   for each objNAConfig in colNAConfig
      intRC = objNAConfig.EnableStatic(strIP,strMask)
      intRC2 = objNAConfig.SetGateways(strGatewayIP)
      if intRC = 0 and intRC2 = 0 then
         WScript.Echo "IP address configured for " & strConnection
      elseif intRC = 1 or intRC2 = 1 then
         WScript.Echo "You must reboot for the changes to take effect for " & _
                      strConnection
      else
         WScript.Echo "There was an error configuring IP for " & _
                      strconnection & ": " & intRC & " and " & intRC2
      end if
   next
next

If anyone has any idea how to add this would you please let me know, Also i was thinking since i configure and reinstall a lot of computers on a daily basis is there a way to write a process script that when i run it, it will run the installers of the programs i need to install, for example after reformatting a computer i need to install the basics like my flash, adobe reader, IE8 ect...and if i could just run the script to install one then the next and then the next and then reboot that would be sweet. might be a long shot tho.
 
Setting Network Parameters Using WMI (Part 2) — ServerWatch.com

The script uses the following methods:

SetWINSServer sets the IP addresses of the primary and secondary WINS servers.
SetDNSServerSearchOrder sets the IP addresses of the DNS servers in the order in which they will be used. The input parameter of this method is the array of strings containing individual IP addresses of DNS servers.
SetDNSDomain sets the connection specific DNS suffix (this is global setting on Windows NT 4.0)
SetTCPIPNetBIOS sets the option to use NETBIOS over TCP/IP. This method accepts one of two values as its parameter: 1 (NetBIOS enabled) or 2 (NetBIOS disabled).
 
Status
Not open for further replies.
Back
Top Bottom