Jump to content
Sign in to follow this  
jwfel

Help! Change Server DNS

Recommended Posts

jwfel

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

Share this post


Link to post
Share on other sites
Authenticity

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 ;]

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.