
CODE: [Copy to clipboard]@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 "[a-z]">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
CODE: [Copy to clipboard]熟用管道命令, && || 可以代替 if errorlevel 感觉简单多了啊~@
useage: [@command]
Hide the command which is behind it.
&
usage: [first command&second command]
No matter the first command succeed or failed, execute the second command.
&&
usage: [first command&&second command]
While first command succeed ,then second command.
||
usage: [first command||second command]
While first command failed,then second command.
|
usage: [first command|second command]
Communicate the result of first command to the parameters of the second command.
>
usage: [command>file]
Output the result of the command into a file and cover the original contents.
>>
usage: [command>>file]
Output the result of the command into a file,but will not cover the original contents.
CODE: [Copy to clipboard]@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 "[a-z]">nul&&call :lp||goto 1
:lp
for /f "skip=4 tokens=3,7 delims=: " %%a in ('netstat -anop tcp') do (
echo %%a|findstr /c:"%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
| Quote: | |
|
| 欢迎光临 中国DOS联盟论坛 (http://cndos.fam.cx/forum/) | Powered by Discuz! 2.5 |