Get MAC Address

Got a problem you cannot solve? Try here.
Adam
Posts: 26
Joined: Tue Jul 10, 2012 5:28 am

Get MAC Address

Postby Adam » Mon Dec 01, 2014 5:40 am

Hi

I can't seem to find any features where it is possible to get the MAC address. Is there anything, or does anyone know of any other method?

Thanks
Adam

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: Get MAC Address

Postby FrancescoT » Mon Dec 01, 2014 12:56 pm

Dear Adam,

unfortunately InstallAware doesn't have any built-in command for that.

You may try to use the "GetAdaptersInfo" WIN API to programatically Get MAC address.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365917(v=vs.85).aspx

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE

bokkie
Posts: 767
Joined: Sun Feb 08, 2009 6:30 am

Re: Get MAC Address

Postby bokkie » Thu Dec 04, 2014 4:45 am

Adam,

I just noticed your post. If you're interested I wrote a plugin to get the MAC address. If you want it let me know.
Peter. Smartly dressed, he still resembles an unmade bed.
InstallAware MVP

edan
Posts: 2
Joined: Tue Jul 12, 2016 10:48 am

Re: Get MAC Address

Postby edan » Tue Jul 12, 2016 11:05 am

Peter,

I am interested in your plugin to get MAC address.

Thank you.
-edan

bokkie
Posts: 767
Joined: Sun Feb 08, 2009 6:30 am

Re: Get MAC Address

Postby bokkie » Tue Jul 12, 2016 2:56 pm

Edan,

Give me a little time to recompile it and test it. For some reason, it's throwing an access violation. I'll need to do some debugging to see what's causing it. I'll come back to you hopefully tomorrow.
Peter. Smartly dressed, he still resembles an unmade bed.
InstallAware MVP

edan
Posts: 2
Joined: Tue Jul 12, 2016 10:48 am

Re: Get MAC Address

Postby edan » Thu Jul 14, 2016 7:55 pm

Peter,

Thank you for looking in to it. However,...

I found a way to do it using vbscript to write the MAC to an INI format file. From within my IA script I use "Run Program" to run the vbs script. I then use the IA "Get INI File Settings" command to pull the MAC into my install script.

The basics of the vbs script are as follows. If there is more than one enabled network adapter you need to figure out which MAC you want from the other information available within the colItems object.

Dim ObjWMI: Set ObjWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Dim colItems : Set colItems = ObjWMI.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
Dim adapterCFG, MACAddress
Dim objFSO, objFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
For each adapterCFG in colitems
objFile.WriteLine("[NetworkAdapter_" & adapterCFG.Index & "]")
objFile.WriteLine("Description=" & adapterCFG.Description)
objFile.WriteLine("MACAddress=" & adapterCFG.MACAddress)
Next
objFile.Close

bokkie
Posts: 767
Joined: Sun Feb 08, 2009 6:30 am

Re: Get MAC Address

Postby bokkie » Fri Jul 15, 2016 5:11 pm

Edan,

Happy to read you did it using vbscript. In my plugin (c#) I use this namespace:

using System.Net.NetworkInformation

and I iterate through the collection using:

foreach(string pa in from ni in NetworkInterface.GetAllNetworkInterfaces() where ni.OperationalStatus == OperationalStatus.Up select ni.GetPhysicalAddress().ToString().Trim())
{
...
}

Otherwise, wmi works just as well.
Peter. Smartly dressed, he still resembles an unmade bed.
InstallAware MVP


Return to “Technical Support”

Who is online

Users browsing this forum: Bing [Bot] and 169 guests