@echo off for /f "delims=" %%a in ('wmic NIC where "NetEnabled='TRUE'" get MACAddress^,NetConnectionID /value^|find "="') do set %%a for /f "delims=" %%a in ('wmic NICCONFIG where "MACAddress='%MACAddress%'" get IPAddress /value^|find "="') do set %%a for /f "delims={," %%a in ("%IPAddress%") do set ip=%%~a for /f "tokens=1-4 delims=." %%a in ("%ip%") do set last=%%d echo;%ip% echo;%last% echo;%NetConnectionID%