I want to find the MAC address of network adopter, I have a working code too but my problem is it only works if IP addres is enabled otherwise it won't get the address is there any solution to find MAC address even if IP Enabled is false if its possible update me with sample code

Here is my code to find MAC

Dim myWMI As Object, myObj As Object, Itm
Set myWMI = GetObject("winmgmts:\\.\root\cimv2")
Set myObj = myWMI.ExecQuery("SELECT * FROM " & _
                 "Win32_NetworkAdapterConfiguration " & _
                 "WHERE IPEnabled = True")
For Each Itm In myObj
Dim macme As String
Dim NewMac As String
macme = Itm.MACAddress
NewMac = Replace(macme, ":", "")
Text1.Text = NewMac
    Exit For
Next

Recommended Answers

All 3 Replies

Can't you just remove the WHERE condition?

I tried to remove it WHERE statement but getting errors but
Yes i can if find anyother working solution, i copied this code from internet as I am new to it
any other solution to grab the mac address of LAN card only if LAN is not available then check for wireless
the only thing I required is to grab single/one MAC address that works and keep constant if IP given or not given.

What error messages are you getting ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.