@echo off :loop cls echo Monitoring TCP Connections... echo. set /p option="Enter 'a' for all TCP connections or 'e' for established connections: " if "%option%"=="a" ( netstat -an | findstr /c:"TCP" /c:"Active Connections" ) else if "%option%"=="e" ( netstat -an | findstr /c:"ESTABLISHED" )else ( echo Invalid option. Please try again. ) timeout /t 5 > nul goto loop