如何获取通过Java程序运行的exe的进程ID [英] How to get a process id of exe running through java program

查看:676
本文介绍了如何获取通过Java程序运行的exe的进程ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过Java运行时api运行exe

I am running a exe through java runtime api

     Process process = runTime.exec("cmd.exe /c start abc.exe "+Id, null, new       File("D:/My"));

并使用jna这样检索进程ID-

and retrieving the process id using jna like this -

    Kernel32.INSTANCE.GetProcessId((Long) f.get(process));

但是进程ID返回的不是abc.exe,而是cmd.exe .....我需要abc.exe的进程ID.不知道该如何得到,任何人都可以帮忙.

but the process id return is not of abc.exe but of cmd.exe ..... i need the process id of abc.exe . Do not know how to get that can anyone help.

推荐答案

我无法通过cmd.exe获取exe的进程ID,但我的目的是通过使cmd.exe等待直到子exe运行而实现的使用以下命令

i cant get the process id of the exe start through cmd.exe but my purpose was served by making the cmd.exe to wait till the child exe is running using following command

Process process = runTime.exec("cmd.exe /c start /wait abc.exe "+Id, null, new       File("D:/My"));

然后我使用jna-api得到了cmd.exe的进程ID

and i got the process id of the cmd.exe using jna-api

这篇关于如何获取通过Java程序运行的exe的进程ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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