You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
572 B
Batchfile
25 lines
572 B
Batchfile
|
5 years ago
|
@echo off&setlocal EnableDelayedExpansion
|
||
|
|
set Port=
|
||
|
|
set Dstport=9091
|
||
|
|
|
||
|
|
for /F "usebackq skip=4 tokens=2,5" %%a in (`"netstat -ano -p tcp"`) do (
|
||
|
|
for /F "tokens=2 delims=:" %%k in ("%%a") do (
|
||
|
|
set Port=%%k
|
||
|
|
)
|
||
|
|
echo !Port! %%b >>portandpid.txt
|
||
|
|
)
|
||
|
|
for /F "tokens=2 delims=:" %%c in ("%1") do (
|
||
|
|
set Port=%%c
|
||
|
|
)
|
||
|
|
for /F "tokens=1,2 delims= " %%d in (portandpid.txt) do (
|
||
|
|
echo %%d
|
||
|
|
echo %Dstport%
|
||
|
|
if %%d == %Dstport% taskkill /f /pid %%e
|
||
|
|
)
|
||
|
|
del portandpid.txt
|
||
|
|
set Port=
|
||
|
|
set Dstport=
|
||
|
|
goto :eof
|
||
|
|
|
||
|
|
echo '结束了'
|