Invalid root in registry error


Some machines at my location have dhcp configured but their DNS servers are static.  I found a script this is trying to read which network interfaces have dynamic dns servers set verses staticly configured ones by drilling down to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\ and iterating through the keys looking for "nameserver" values.

This script runs as expected on my local machine. When I enter a remote system I get the "invalid root in registry" error.

 The interesting thing is that the error message give me the path on the remote system.  I can tell because the output shows the remote systems NIC GUID.

Here is the script:

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set WshShell = WScript.CreateObject("WScript.Shell")
DNSserv= ""
Regkey = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\"

Set IPDevSet = objWMIService.ExecQuery _
("Select SettingID from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")

For Each IPDev in IPDevSet

str =  Regkey & IPDev.SettingID & "\NameServer"

out= WshShell.RegRead(str)
wscript.echo out

Any thougths?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi, you need to use the StdRegProv WMI namespace. The RegRead method doesn't support remote systems, so it's trying to read the remote path on your computer.  Look up the GetStringValue method on MSDN for an example.



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mcalo1Author Commented:
thanks for the help Rob.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.