tags:

views:

105

answers:

1

Hi. I'm trying to set the Alternate DNS Server using .NET. I have managed to set the main DNS server by using this bit of code.

ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
                ManagementObjectCollection moc = mc.GetInstances();
                foreach (ManagementObject mo in moc)
                {
                    if ((bool)mo["IPEnabled"])
                    {
                        ManagementBaseObject objdns = mo.GetMethodParameters("SetDNSServerSearchOrder");
                        if (objdns != null)
                        {
                            string[] s = { "127.0.0.1" };
                            objdns["DNSServerSearchOrder"] = s;
                            mo.InvokeMethod("SetDNSServerSearchOrder", objdns, null);
                        }
                    }
                }

Now I need to figure out how to set the Alternate DNS Server. Please help. Thanks in advance!

+2  A: 

most probably

string[] s = { "127.0.0.1", "127.0.0.2" };
just somebody
That did it. Damn I'm stupid. Thanks a lot!
Prasannah