tags:

views:

119

answers:

3

Hi All,

Is there any way i can retrieve MAC Address when Network Adapter is disabled in .net?

Thanks in advance,

+1  A: 

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.

Jaroslav Jandek
+1  A: 

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;
    }
Michael Stoll
+2  A: 

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.

lazynewbie