Page 1 of 1
Get MAC Address
Posted: Mon Dec 01, 2014 5:40 am
by Adam
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
Re: Get MAC Address
Posted: Mon Dec 01, 2014 12:56 pm
by FrancescoT
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).aspxRegards
Re: Get MAC Address
Posted: Thu Dec 04, 2014 4:45 am
by bokkie
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.
Re: Get MAC Address
Posted: Tue Jul 12, 2016 11:05 am
by edan
Peter,
I am interested in your plugin to get MAC address.
Thank you.
-edan
Re: Get MAC Address
Posted: Tue Jul 12, 2016 2:56 pm
by bokkie
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.
Re: Get MAC Address
Posted: Thu Jul 14, 2016 7:55 pm
by edan
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
Re: Get MAC Address
Posted: Fri Jul 15, 2016 5:11 pm
by bokkie
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.