高手们无视吧。。。- -||
@echo off
title PORT T0 PROCESS
:1
cls&echo.&set "tmp="
set "port="
set/p "port=Input the port id: "
if not defined port goto 1
echo %port%|findstr /v /i "">nul&&call :lp||goto 1
:lp
for /f "skip=4 tokens=3,7 delims=: " %%a in ('netstat -anop tcp') do (
echo %%a|findstr "\<%port%\>">nul&&(set tmp=A&echo.&echo PROCESS INFOMATION:&echo.&tasklist /fi "pid eq %%b" 2>nul)
)
if not defined tmp echo.&echo No %port% port running
pause>nul&goto 1
@
useage:
Hide the command which is behind it.
&
usage:
No matter the first command succeed or failed, execute the second command.
&&
usage:
While first command succeed ,then second command.
||
usage:
While first command failed,then second command.
|
usage:
Communicate the result of first command to the parameters of the second command.
>
usage:
Output the result of the command into a file and cover the original contents.
>>
usage:
Output the result of the command into a file,but will not cover the original contents.
熟用管道命令, && || 可以代替 if errorlevel 感觉简单多了啊~