1. 首先用netstat -ano | find “端口號”查出進程號
明明有端口號是17568和18892, 如何確定是17568呢
2. takslist 查詢當前的進行
3. 如何殺死進程呢 tasklist /pid ${xx}
發現不行呢,權限不夠,用管理員權限運行cmd,發現又報錯了,說要強制執行才可以,加上-F
總結下:
taskkill是Windows命令行里終止指定程序“進程”的命令。
/f 表示強制終止
/im 表示指定的進程名稱,例如“explor.exe"
/pid 表示指定的進程ID進程號
taskkill /f /im javaw.exe
taskkill /f /pid 3352
總結下: taskkill是Windows命令行里終止指定程序“進程”的命令。 /f 表示強制終止 /im 表示指定的進程名稱,例如“explor.exe" /pid 表示指定的進程ID進程號 taskkill /f /im javaw.exe taskkill /f /pid 3352
windows批處理刪除指定進程
@echo off setlocal enabledelayedexpansion set /p port=請輸入端口號: for /f "tokens=1-5" %%a in ('netstat -ano ^| find ":%port%"') do ( if "%%e%" == "" ( set pid=%%d ) else ( set pid=%%e ) echo !pid! taskkill /f /pid !pid! ) pause
上面一種
@echo off & color 3d & setlocal enabledelayedexpansion ::ipconfig>ip.txt netstat -aon |findstr 8083>pid.txt for /f "delims=" %%a in (pid.txt) do ( for /f "tokens=1* delims=:" %%i in ('call echo %%a^|find /i "TCP"') do ( echo %%a ::讀取出內容過濾后,寫入另一個記事本中 rem Echo %%a>>"text.txt" ) ) rem 讀取文件中內容 set /P OEM=<pid.txt rem 截取文件中的字符串 echo %OEM:~71,76% taskkill /f /pid %OEM:~71,76%