@echo off for /f "delims=" %%i in ('netstat -a^|findstr 6660') do (set a=%%i) echo %a% pause ::只返回一行数值,否则,它会只取最后一个,即最后一行。