將以下指令複製到文字檔另存為xxx.bat執行即可
@echo off :home setlocal enabledelayedexpansion netstat -na|find "TCP" /c >www FOR /F "usebackq tokens=*" %%a IN (www) DO (SET _TCP=%%a) echo 目前TCP連線總數%_TCP% netstat -na|find "UDP" /c >www FOR /F "usebackq tokens=*" %%b IN (www) DO (SET _UDP=%%b) echo 目前UDP連線總數%_UDP% set /a _count=(%_TCP%+%_UDP%) echo 目前ALL連線總數為%_count% endlocal timeout 10 cls goto home