Windows杀掉进程
常规做法
查看:任务管理器
- 找到想杀掉的进程 -> 选择进程 -> 按右键,点击【结束任务】
执行:tasklist命令,会显示PID、会话名、内存使用等信息
C:\Users\Administrator>tasklist
映像名称 PID 会话名 会话# 内存使用
========================= ======== ================ =========== ============
System Idle Process 0 Services 0 8 K
System 4 Services 0 96 K
Secure System 72 Services 0 39,764 K
Registry 132 Services 0 36,708 K
smss.exe 740 Services 0 948 K
csrss.exe 824 Services 0 4,252 K
wininit.exe 912 Services 0 3,684 K
csrss.exe 928 Console 1 5,660 K
services.exe 984 Services 0 9,092 K
LsaIso.exe 96 Services 0 2,912 K
chrome.exe 25852 Console 1 63,096 K
chrome.exe 30152 Console 1 38,784 K
chrome.exe 31520 Console 1 25,360 K
chrome.exe 14756 Console 1 77,028 K
java.exe 31040 Console 1 156,140 K
conhost.exe 27536 Console 1 11,100 K
SearchProtocolHost.exe 29976 Services 0 11,780 K
Taskmgr.exe 4488 Console 1 67,972 K
dllhost.exe 28080 Console 1 12,296 K
SearchFilterHost.exe 24760 Services 0 7,484 K
TrustedInstaller.exe 23124 Services 0 7,644 K
svchost.exe 15144 Services 0 7,592 K
TiWorker.exe 4540 Services 0 29,900 K
git.exe 27220 Console 1 5,044 K
conhost.exe 30724 Console 1 11,104 K
git.exe 13556 Console 1 5,856 K
sh.exe 23824 Console 1 7,364 K
ssh.exe 23692 Console 1 9,024 K
tasklist.exe 27324 Console 1 8,588 K
WmiPrvSE.exe 5024 Services 0 10,284 K杀掉:2种方法
按指定【映像名称】杀掉,语法如下,-f是强制杀掉,不想强制杀掉,去掉:/f即可
taskkill /im {映像名称} /f
示例:注意,本命令会杀掉:映像名称一致的所有进程,慎用,建议按下面的指定PID方式杀掉进程。
D:\dev\idea>taskkill /im Postman.exe /f
成功: 已终止进程 "Postman.exe",其 PID 为 19772。
成功: 已终止进程 "Postman.exe",其 PID 为 22300。
成功: 已终止进程 "Postman.exe",其 PID 为 21520。
成功: 已终止进程 "Postman.exe",其 PID 为 15300。
成功: 已终止进程 "Postman.exe",其 PID 为 18028。
成功: 已终止进程 "Postman.exe",其 PID 为 23388。
成功: 已终止进程 "Postman.exe",其 PID 为 9940。按指定【PID】杀掉进程,语法
taskkill /pid {pid} /F
示例
D:\dev\idea>taskkill /pid 19172
错误: 无法终止 PID 为 19172 的进程。
原因: 只能强行终止这个进程(带 /F 选项)。
D:\dev\idea>taskkill /pid 19172 /F
成功: 已终止 PID 为 19172 的进程。
Java进程
参照我之前一篇文章,可以用JDK提供的命令:jps查看java进程
延展知识
查找被占用的端口号,用netstat结合findstr命令查看
netstat -aon | findstr 端口号
示例:最后一行是PID信息
D:\dev\idea>netstat -aon | findstr 3003
TCP 0.0.0.0:3003 0.0.0.0:0 LISTENING 1476
TCP [::]:3003 [::]:0 LISTENING 1476
UDP 0.0.0.0:63003 *:* 4596继续举例子:tasklist结合findstr可以查看:映像名称
D:\dev\idea>tasklist | findstr java
java.exe 27060 Console 1 6,712 K
java.exe 10812 Console 1 35,848 K
java.exe 31040 Console 1 16,220 K