If you need to find only permanent MAC address, you should begin by filtering the NICs that are physical:
wmic nic where "PhysicalAdapter='True'"
Once you have that list, you'll find that some virtual interfaces still appear as physical.
A good way to filter them is to check their device path since only real network cards are connected to the PCI bus.
This also would apply to USB bus, but since those cards aren't permanently connected, you can safely ignore them.
A good way to retrieve the device path togheter with the MAC address would be
wmic nic where "PhysicalAdapter='True'" get MACAddress,PNPDeviceID
which would output something like:
MACAddress PNPDeviceID
E0:94:67:XX:XX:XX PCI\VEN_8086&DEV_3165&SUBSYS_40108086&REV_81\E094XXXXXXXXXXXXXX
D8:CB:8A:XX:XX:XX PCI\VEN_1969&DEV_E0A1&SUBSYS_115A1462&REV_10\FFEFXXXXXXXXXXXXXX
E0:94:67:XX:XX:XX BTH\MS_BTHPAN\6&5XXXXXXXXXX
In the above example you can see two "real" ethernet network interfaces (wifi and eth), and a bluetooth device.
Just filter by keyword PCI and you got yourself the list of non mutable mac addresses.
You can filter via inno setup turbo pascal functions, or via cmd.
The final result could look like:
wmic nic where "PhysicalAdapter='True'" get MACAddress,PNPDeviceID | findstr "PCI"
If you want to show only the MAC addresses, you can wrap the whole thing in a batch script (which IMO isn't the best idea since it's a messy script language):
for /f "delims=" %%i in ('wmic nic where "PhysicalAdapter='True'" get MacAddress^,PNPDeviceID ^| findstr PCI') do (set res=%%i && echo %res:~0,17%)
Note the ^
sign before the comma and the pipe, that acts like an escape character so cmd doesn't take them as litterls.
There's also the Inno Setup way of doing by using a Pascal script.
Here's one I've modified (original here) to only list the MAC addresses of physical permanent interfaces.
Results in variable List:
WbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
WbemServices := WbemLocator.ConnectServer('localhost', 'root\cimv2');
WQLQuery := 'Select MACAddress,PNPDeviceID from Win32_NetworkAdapter where PhysicalAdapter=true';
WbemObjectSet := WbemServices.ExecQuery(WQLQuery);
if not VarIsNull(WbemObjectSet) and (WbemObjectSet.Count > 0) then
begin
Result := WbemObjectSet.Count;
SetArrayLength(List, WbemObjectSet.Count);
for I := 0 to WbemObjectSet.Count - 1 do
begin
WbemObject := WbemObjectSet.ItemIndex(I);
if not VarIsNull(WbemObject) then
begin
if pos('PNP', WbemObject.PNPDeviceID) = 1 then
begin
List[I].MacAddress := WbemObject.MACAddress;
end;
end;
end;
end;
Note that this pascal script only works with win7+.
Hope one of these solutions fits you.