Jump to content

Help! Change Server DNS


 Share

Recommended Posts

Hello everyone,

I am very new to AutoIt. And having some problems... All I need is to have a script to change DNS server settings on 150 servers.

here is a little script that I wrote, but getting an error:

Const INPUT_FILE_NAME = "C:\Scripts\Servers.txt"

Const FOR_READING = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFile = objFSO.OpenTextFile(INPUT_FILE_NAME, FOR_READING)

strServers = objFile.ReadAll

objFile.Close

arrComputers = Split(strServers, vbCrLf)

For Each strServer In arrComputers

On Error Resume Next

Set objWMIService = GetObject("winmgmts:" _

& "{impersonationLevel=impersonate}!\\" & strServer & "\root\cimv2")

Set colNetCards = objWMIService.ExecQuery _

("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled =

True")

For Each objNetCard in colNetCards

arrDNSServers = Array("x.x.x.x", "x.x.x.x")

objNetCard.SetDNSServerSearchOrder(arrDNSServers)

Exit For

Next

Next

Link to comment
Share on other sites

Start by reading the help file so you can have understanding of the syntax. It's pretty close to Visual Basic syntax so you'll get it very fast. For example, variables or constants names are followed by a dollar sign '$' like $Var, or for example, CreateObject's AutoIt counterpart is ObjCreate...

Good-luck ;]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...