ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration"); ManagementObjectCollection moc = mc.GetInstances(); foreach (ManagementObject mo in moc) { if (!(bool)mo["IPEnabled"]) continue; mo.InvokeMethod("SetDNSServerSearchOrder", null); mo.InvokeMethod("EnableStatic", null); mo.InvokeMethod("SetGateways", null); mo.InvokeMethod("EnableDHCP", null); break; }