Hi All,
Is there any way i can retrieve MAC Address when Network Adapter is disabled in .net?
Thanks in advance,
Hi All,
Is there any way i can retrieve MAC Address when Network Adapter is disabled in .net?
Thanks in advance,
You can parse the output of the "ipconfig /all" command.
Also, you can use the GetAdaptersInfo WINAPI function.
It might be possible to use the ManagementClass and Windows Management Instrumentation.
I have never tried that for disabled adapters though.
You can use WMI:
public static string GetMACAddress()
{
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc = mc.GetInstances();
string MACAddress=String.Empty;
foreach(ManagementObject mo in moc)
{
if(MACAddress==String.Empty) // only return MAC Address from first card
{
MACAddress= mo["MacAddress"].ToString() ;
}
mo.Dispose();
}
return MACAddress;
}
Refer this link.
http://msdn.microsoft.com/en-us/library/system.net.networkinformation.physicaladdress.aspx
The example here displays physical address of all interface irrespective of their operational stage. HTH.