How to Change DNS with C# on Windows 10
<p>I'm trying to change the DNS on Windows 10 through VB.NET.</p>

<p>I have code that works on Windows 7, however it does not work on Windows 10.</p>

<p>Here is my code for Windows 7 that changes the DNS:</p>

<pre><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 = { "192.168.XX.X", "XXX.XX.X.XX" };
            objdns["DNSServerSearchOrder"] = s;
            mo.InvokeMethod("SetDNSServerSearchOrder", objdns, null);
</code></pre>

<p>My question is, how do I get this to work on Windows 10 OS?</p>