:start
@echo off&setlocal enabledelayedexpansion
title Port Mapping Viewer Lite v10
set "index=0"
set "totalPort=0"
for /f "delims=, tokens=1,2" %%a in ('tasklist /fo csv /nh') do (
set "pname_%%~b=%%~a"
)
for /f "skip=4 tokens=1,2,3,4,5" %%a in ('netstat -ano') do (
if "%%c"==":" (
set/a index+=1
set "port_!index!=%%a %%b %%d"
)
if "%%c"=="[::]:0" (
set/a index+=1
set "port_!index!=%%a %%b %%e"
)
if not "%%e"=="" (
set/a index+=1
set "port_!index!=%%a %%b %%e"
)
)
for /l %%a in (%index%,-1,1) do (
for /f "tokens=1,2,3" %%i in ("!port_%%a!") do (
for /f "delims=: tokens=2,3,6" %%o in ("%%j") do (
if "%%p"=="" (
set "port=%%o"
) else (
if "%%q"=="" (
set "port=%%p"
) else (
set "port=%%q"
)
)
)
call :print "%%i" "!port!" "%%k"
)
)
for /f "delims== tokens=1" %%i in ('set output#') do (
for /f "delims=# tokens=2,3,4" %%a in ("%%i") do (
echo [%%a ^| Pid: %%b] -^> [%%c]
)
)
echo&echo Total number of port opened: [!totalPort!]&echo
set/p "action=[Press T to exit or other keys to refresh the table] "
if /i "%action%"=="T" (
exit
)
cls
endlocal
goto start
pause
:print
set "protocol=%~1"
set "port=%~2"
set "pid=%~3"
set "process=!pname_%pid%!"
if "%process%"=="" (
set "process=Unknown"
)
if not defined %port% (
set "output#%process%#%pid%#%protocol%: %port%#=aa"
set "%port%=aa"
set/a totalPort+=1
)
exit/b
可以帮你检测出哪个进程开启了哪个端口查出来之后,直接写个批处理:
taskkill /im 那个进程的名字
以上就是关于怎么写bat批处理文件开机自动杀pid 电脑每次开机8080端口被占用,每次在cmd杀pid才可以使用。全部的内容,包括:怎么写bat批处理文件开机自动杀pid 电脑每次开机8080端口被占用,每次在cmd杀pid才可以使用。、、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)