如何在Java中查找并终止运行Win-Processes?

如何在Java中查找并终止运行Win-Processes?

问题描述:

我需要一种Java方法来查找正在运行的Win进程,我知道可执行文件的名称。我想看看它是否正在运行,如果我找到它,我需要一种方法来终止进程。

I need a Java way to find a running Win process from which I know to name of the executable. I want to look whether it is running right now and I need a way to kill the process if I found it.

你可以使用命令行窗口工具任务列表 taskkill 并使用从Java调用它们Runtime.exec ()

You can use command line windows tools tasklist and taskkill and call them from Java using Runtime.exec().