Announcement

Collapse
No announcement yet.

DNS IP configuration to all clients by VBscript

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • DNS IP configuration to all clients by VBscript

    Dear Members,


    I need some help regarding DNS IP configuration to all my clients(windows xp pro)
    I want to build vbscript to enable me to distribute it

    My scope of work is:

    In every brunch I have 15 clients, I need to setup a script that change my dns ip configuration priority in the network adapters.


    Thank You
    Yours
    Ron

  • #2
    Re: DNS IP configuration to all clients by VBscript

    Not VBScript, I realise, but it may be useful for you to have a look at this command line, which saves IP configuration including DNS:

    Code:
    netsh -c interface dump > settings.txt
    So, have a look at the settings.txt file and see how it works. Then, this command will fetch those settings and load them into the network settings:
    Code:
    netsh -f settings.txt
    So you could make a batch file using the above command for your use and run it accordingly (at startup, logon etc).
    Best wishes,
    PaulH.
    MCP:Server 2003; MCITP:Server 2008; MCTS: SBS2008

    Comment


    • #3
      Re: DNS IP configuration to all clients by VBscript

      add this vbs-code to the Computer - Startup script:
      Code:
      'http://msdn2.microsoft.com/en-US/library/aa393295.aspx
      'http://www.microsoft.com/technet/scriptcenter/resources/qanda/apr05/hey0425.mspx
      
      
      arrNewDNSServerSearchOrder = Array( "192.168.1.3", _
                                          "192.168.1.4"  )
                                          
      'to find the right adapter(s) to change:
      strOneOfTheOldDNSServers = "192.168.1.2"
      
      
      strComputer = "."
      Set objWMIService = GetObject("winmgmts:" _
          & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
      
      
      Set colNetCards = objWMIService.ExecQuery _
          ("Select DNSServerSearchOrder From Win32_NetworkAdapterConfiguration")
      
      For Each objNetCard in colNetCards
        blnFound = 0
        arrDNSServerSearchOrder = objNetCard.DNSServerSearchOrder
        If Not IsNull(arrDNSServerSearchOrder) Then
          For i = 0 to UBound(arrDNSServerSearchOrder)
            If (arrDNSServerSearchOrder(i) = strOneOfTheOldDNSServers) Then
              arrDNSServerSearchOrder = Array()
              objNetCard.SetDNSServerSearchOrder(arrDNSServerSearchOrder)
              wscript.sleep 600
              arrDNSServerSearchOrder = arrNewDNSServerSearchOrder
              objNetCard.SetDNSServerSearchOrder(arrDNSServerSearchOrder)
              Exit For
            End If
          Next    
        End If
      Next
      \Rems

      This posting is provided "AS IS" with no warranties, and confers no rights.

      __________________

      ** Remember to give credit where credit's due **
      and leave Reputation Points for meaningful posts

      Comment

      Working...
      X