Is there any way i can retrieve MAC Address when Network Adapter is disabled in .net?
Thanks in advance,
It is not possible to get the MAC address of an adapter which is disabled: this is because getting the MAC address requires querying the driver, and the driver for a disabled adapter is not loaded (source).
You can, however get the MAC address of an adapter which is not currently connected.
The WMI route is no good here, because it shows the MAC address as null for adapters which are not connected. The good news is that the NetworkInterface.GetAllNetworkInterfaces()
route works just fine:
// using System.Net.NetworkInformation;
var nics = NetworkInterface.GetAllNetworkInterfaces();
// pick your NIC!
var selectedNic = nics.First();
var macAddress = selectedNic.GetPhysicalAddress().ToString();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With