| 目的 | 命令 | 關鍵參數 |
|---|---|---|
| 列出所有進程 | tasklist | /v 詳細、/fi "imagename eq nginx.exe" 過濾 |
| 查看端口-PID 映射 | netstat -ano | -a全部、-n數字、-o顯示 PID |
| 終止進程 | taskkill /PID <PID> [/F] | /F 強制、/T 連同子進程 |
netstat -ano | findstr :8080TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 1448tasklist /fi "pid eq 1448"taskkill /PID 1448 /F (加 /F 強制殺掉服務進程)。# 只看 TCP 監聽
netstat -ano | findstr "LISTENING"
# 找出某進程開啟的所有端口
netstat -ano | findstr " 1448 "
# 批量殺掉某名稱所有進程
taskkill /IM nginx.exe /F
# PowerShell 更強大 (Win7+ 預裝)
Get-NetTCPConnection -LocalPort 8080 | Select-Object -ExpandProperty OwningProcess
Stop-Process -Id 1448 -Force
tasklist/taskkill;若無,可從 Windows Server 2003 Resource Kit Tools 獲取。netstat -ano 輸出中 0.0.0.0 表示監聽所有介面,127.0.0.1 僅本地回環。tasklist /v /fi "pid eq 1448" > dump.txt 留存證據。resmon.exe) → CPU/網絡頁籤圖形化查看。Get-Process, Get-NetTCPConnection 物件化管道操作。掌握 tasklist | netstat -ano | taskkill 鐵三角,即可在無 GUI/舊版 Windows 環境快速定位並處理端口佔用問題。