LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting Mac Address reliably on windows

I need to be able to find the mac address on windows computers running my code. I have seen the vi get_remote_mac_address that uses the ipconfig /all command and parses the result to find the mac address.

The problem with this vi is that it looks for the string "Physical Address" to find the location of the mac address. This string is not the same on windows system with different language, for example on a German version of Windows XP the string is "Physikalische Adresse".

To get around this problem I made a new vi that looks for a mac address pattern in the ipconfig /all result and returns all mac addresses it finds.

 

My question is: Does anybody have experience with getting the mac address on computers with non English Windows? Or if anybody could test the attached vi to see how it works on different language versions of windows and post back the results.

 

Thank you,

Thorarinn Andresson

0 Kudos
Message 1 of 8
(5,926 Views)
You could use the UuidCreateSequential function. The last 6 bytes of this value should be your MAC address.
Message 2 of 8
(5,917 Views)

You can use .NET to retrieve the NetworkInterface.PhysicalAddress property.

 

 

Message Edited by Phillip Brooks on 11-20-2009 02:29 PM

Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

0 Kudos
Message 3 of 8
(5,900 Views)

I hate .Net Smiley Very Happy

 

For anyone not wanting to involve 5 software layers to do this there is also a solution here.

Rolf Kalbermatter
My Blog
Message 4 of 8
(5,882 Views)

I appreciate all the suggestions.

 

Rolf Kalbermatter, do you know how your library works on different version of Windows? I have tested it on XP, Vista & Windows Server 2003 and it works well, on Windows Vista the vi returned more results then the ipconfig /all command. I have not been able to test it on Windows 7 or Windows Server 2008.

 

Best Regards,

Thorarinn.

0 Kudos
Message 5 of 8
(5,843 Views)

I have not tested it on newer Windows versions myself. However I would not expect it to not work except of privilege reasons. I could imagine that some of those APIs might require special privileges in VISTA and Windows 7. So try it with standard user rights to be sure.

 

And since .Net most likely makes use of the same low level APIs at some point I would expect it to have similar privilege trouble if there are any.

Message Edited by rolfk on 11-23-2009 12:05 PM
Rolf Kalbermatter
My Blog
Message 6 of 8
(5,841 Views)

rolfk wrote:

I hate .Net Smiley Very Happy

 

For anyone not wanting to involve 5 software layers to do this there is also a solution here.


I almost prefaced my post with "There are those that will hate the fact that I'm suggesting .NET, but..."

 

I like Windows XP over Vista or Win7, but the day will come when I will be dragged kicking and screaming to it...

 

The dark side is strong Rolf, do not resist it....  😄


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

0 Kudos
Message 7 of 8
(5,824 Views)

@Phillip Brooks wrote:
I almost prefaced my post with "There are those that will hate the fact that I'm suggesting .NET, but..."

I like Windows XP over Vista or Win7, but the day will come when I will be dragged kicking and screaming to it...

 

The dark side is strong Rolf, do not resist it....  😄


We must resist assimilation! Smiley Very Happy

 

And even Windows 7 is still DLL API based in its core. I guess at some point MS will cease documenting new APIs on lower than .Net level but in the bowls of Windows there is still a Windows kernel using syscalls and being interfaced through DLLs. I also don't see .Net kernel drivers happening anytime soon. Smiley Wink

Rolf Kalbermatter
My Blog
0 Kudos
Message 8 of 8
(5,810 Views)