Hi. I have read this article about using WMI to change the settings of NICs ( Article)
But I can't figure out how to change the settings of a single NIC (based on MACaddress, ID or whatever) instead of all NICs !?
Anyone ?
Hi. I have read this article about using WMI to change the settings of NICs ( Article)
But I can't figure out how to change the settings of a single NIC (based on MACaddress, ID or whatever) instead of all NICs !?
Anyone ?
Quick 'n dirty:
foreach(ManagementObject objMO in objMOC)
{
if(!(bool)objMO["ipEnabled"])
continue;
if(!string.Equals(objMO["MACAddress"], "00:ff:xx:xx:xx:xx"))
continue;
// change settings
break;
}
Hi !
One big problem with WMI is usually, that you do not find the information easyly, if an object/property is read-only or updatable.
But the genral way to this - for your loop above - would be this:
objMO["PropertyName"] = "newValue"; //But may be the following (I do it rarely): //objMO["PropertyName"].Value = "newValue"; objMO.Put(); //That it!
Naturally, use the right datatype.
Try it, I hope, it helps!
br--mabra