如何获取Windows中正在运行的应用程序的PID? [英] How to get the PID of running application in Windows?

查看:82
本文介绍了如何获取Windows中正在运行的应用程序的PID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里有我的代码片段:

 ArrayList<String> cmd_exec_installer = new ArrayList<String>();
 cmd_exec_installer.add("file.exe");
 Process proc = new ProcessBuilder(cmd_exec_installer).start();

我想要做的是让进程的PID开始执行file.exe.

What I want to do is to get the PID of the process started executing file.exe.

有没有办法在 Java 中做到这一点?

Is there a way to do that in Java?

推荐答案

这个问题已经得到解答 此处此处.

This question was already answered here and here.

基本上,没有简单的方法可以完成任务,除非您使用 JNI 库或反思,如链接问题中所建议的那样.

Basically, there's no simple way to achieve the task, unless you use the JNI libraries or reflection, as suggested in the linked questions.

这篇关于如何获取Windows中正在运行的应用程序的PID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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