Windows如何杀掉进程?

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
    
  • 7
    点赞
  • 29
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小码匠和老码农

喜欢作者

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值