Changing DNS settings with a batch script

Posted by Dark Training on March 16, 2009 tags: | batch | windows

So, you need to push an updated DNS listing to your users but you can't use a GPO or DHCP. So how can you update DNS with a bat script?

netsh interface ip set dns "Local Area Connection" static 192.168.0.2

That will set the primary DNS value, if you wanted to set secondary values (normally you do), this is how you do it.

netsh interface ip add dns "Local Area Connection" 192.168.0.3

To add more you would repeat the above command