private void UnsetStaticIpv6Setting() { string macaddr = mac.value; resetError(); foreach (ManagementObject nic in WmiBase.Singleton.Win32_NetworkAdapterConfiguration) { if (!(bool)nic["ipEnabled"]) { continue; } if (nic["macAddress"].ToString().ToUpper() != macaddr.ToUpper()) { continue; } IpSettingItem settings = new IpSettingItem(nic["macAddress"].ToString(), "IPV6", "", "", "", ""); if (IpSettings.getIPseting(nic["macAddress"].ToString(), "IPV6", ref settings) == false) { return; } try{ string argument = "interface ipv6 reset"; netshInvoke(argument); IpSettings.removeIPseting(nic["macAddress"].ToString(), "IPV6"); } catch (Exception e) { errorCode.value = "1"; errorMsg.value = e.ToString(); wmisession.Log("Exception " + e.ToString()); return; } } }
private void UnsetStaticIpv4Setting() { string macaddr = mac.value; resetError(); foreach (ManagementObject nic in WmiBase.Singleton.Win32_NetworkAdapterConfiguration) { if (!(bool)nic["ipEnabled"]) { continue; } if (!NicUtil.macsMatch(macaddr, nic["macAddress"].ToString())) { continue; } IpSettingItem settings = new IpSettingItem(nic["macAddress"].ToString(), "IPV4", "", "", "", ""); if (IpSettings.getIPseting(nic["macAddress"].ToString(), "IPV4", ref settings) == false) { return; } try{ setIpv4Network(nic, "EnableDHCP", null, "set back to dhcp"); IpSettings.removeIPseting(nic["macAddress"].ToString(), "IPV4"); } catch (Exception e) { errorCode.value = "1"; errorMsg.value = e.ToString(); wmisession.Log("Exception " + e.ToString()); return; } } }