SETLOCAL ENABLEDELAYEDEXPANSION SET WMIPath=Path Win32_NetworkAdapter SET WMIQuery=WHERE "AdapterType LIKE 'Ethernet%%' AND MACAddress > '' AND NOT PNPDeviceID LIKE 'ROOT\\%%'" FOR /F "tokens=*" %%A IN ('WMIC %WMIPath% %WMIQuery% Get MACAddress /Format:List ^| FIND "="') DO SET %%A SET WMIPath=Path Win32_NetworkAdapterConfiguration SET WMIQuery=WHERE "MACAddress='%%MACAddress%%'" FOR /F "tokens=*" %%A IN ('WMIC %WMIPath% %WMIQuery% Get IPAddress /Format:List ^| FIND "="') DO ( FOR /F "tokens=2 delims==" %%B IN ("%%~A") DO ( IF NOT "%%~B"=="" ( FOR /F "tokens=1 delims={}" %%C IN ("%%~B") DO ( SET IPAddress=!IPAddress!,%%~C ) ) ) ) >> \\Server\Logs\%Today%\%UserName%.log ECHO.%IPAddress:~1%,%MACAddress::=% ENDLOCAL