如何杀除一个所有批处理文件正在运行 [英] how to kill all batch files except the one currently running

查看:117
本文介绍了如何杀除一个所有批处理文件正在运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你怎么能运行哪个taskkills这是目前运行的所有其他cmd.exes,除了在执行该任务kill命令的一个批处理文件?

How can you run a batch file which taskkills all other cmd.exes which are currently running, except for the one that is doing the task kill command?

推荐答案

结合这些2个线程:


  1. how从通过用户名和imagename过滤命令行得到PID

  2. how获得从命令提示符自己的进程的PID在windows

  1. how to get PID from command line filtered by username and imagename
  2. how to get own process pid from the command prompt in windows

您可以写在一个简单的CMD文件是这样的( akillfile.cmd

you can write down something like this in a simple cmd file (akillfile.cmd)

title=dontkillme
FOR /F "tokens=2 delims= " %%A IN ('TASKLIST /FI ^"WINDOWTITLE eq dontkillme^" /NH') DO SET tid=%%A
echo %tid%
taskkill /F /IM cmd.exe /FI ^"PID ne %tid%^"

这篇关于如何杀除一个所有批处理文件正在运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆