Jump to content

Changing Dns Search Order In Win Pe


Recommended Posts

Posted

When our machine boots in WinPE, it gets name of DNS Servers for our primary domain from the DHCP Server. This helps us perform AD queries in the primary domain.

During our build process we would also want to search in a testing AD Domain. That DNS Server is on a different subnet. We want to add the name of the DNS Server (for that testing domain) in our Win PE process, so that we can also search in that testing AD domain alongwith the primary domain.

I am using this VB Code, but it comes back with Automation error. Any help/thoughts on how to get it to work in Win PE Environment?

Dim aDNS(3)

Dim strComputer

Dim objWMIService

Dim errDNS

Dim objItem

Dim colItems

'For all the enthusiasts who will just copy and run this script

msgbox "Please write down your DNS Search order: "

'DNS server search order

aDNS(0) = "1.1.1.1"

aDNS(1) = "1.1.1.2"

aDNS(2) = "1.1.1.3"

adns(3) = "1.1.1.4"

'Set Networking Managing Objects

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = 1")

For Each objItem In colItems

errDNS = objItem.SetDNSServerSearchOrder()

'WScript.Sleep 120000

errDNS = objItem.SetDNSServerSearchOrder(aDNS)

Next

Set objWMIService = Nothing

Set colItems = Nothing

msgbox "Just changed your DNS Search order: "


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
  • Recently Browsing   0 members

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