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")
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"