@echo off
echo Proto Local Address Foreign Address State PID process
for /f "skip=4 tokens=1-5*" %%a in ('netstat -anO') do (
if "%%e"=="" (
for /f "tokens=1-5*" %%i in ('tasklist^|findstr /C:" %%d "') DO (
echo %%a %%b %%c %%d %%e %%i
)
)
if not "%%e"=="" (
if not "%%e"=="0" (
for /f "tokens=1-5*" %%i in ('tasklist^|findstr /C:" %%e "') DO (
echo %%a %%b %%c %%d %%e %%i
)
)
)
)
pause
@echo on