Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 08-12-2009, 11:35 AM   #1 (permalink)
Zindel's Avatar
 
Junior Techie

Join Date: Jun 2005

Posts: 81

Zindel is on a distinguished road

Default IP Config Script

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.

Last edited by Mak213; 08-12-2009 at 08:35 PM. Reason: added code tags
Zindel is offline  
Old 08-13-2009, 06:42 PM   #2 (permalink)
office politics's Avatar
 
It's all just 1s and 0s

Join Date: Jan 2004

Location: in the lab

Posts: 4,410

office politics will become famous soon enough

Default Re: IP Config Script

Setting Network Parameters Using WMI (Part 2) — ServerWatch.com

Quote:
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).

office politics is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
The Internet Movie Script Database IMSDb Osiris Tips, Tricks & Tutorials 0 06-13-2009 02:21 PM
FireFox Speed Up Script Osiris Tips, Tricks & Tutorials 0 05-13-2009 04:11 PM
A shutdown script Nick Windows Operating Systems and Software 3 01-30-2008 03:58 PM