0
在Windows OS中。使用任务列表(getting list of current open process)我收集了正在运行的进程列表。但如何获得该进程的可执行文件的实际路径[文件位置]?在Windows中使用Java获取进程详细信息
有什么办法可以从java中找到最近使用的进程吗?
在Windows OS中。使用任务列表(getting list of current open process)我收集了正在运行的进程列表。但如何获得该进程的可执行文件的实际路径[文件位置]?在Windows中使用Java获取进程详细信息
有什么办法可以从java中找到最近使用的进程吗?
你的意思是这样
import java.io.*;
public class taskmanager {
public static void main(String[] args) throws IOException {
String line;
Process p = Runtime.getRuntime().exec("tasklist.exe");
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
System.out.println(line); //<-- Parse data here.
// new lines from here
String searchPath = "where notepad.exe";
searchProcessPath(searchPath);
}
input.close();
}
public static void searchProcessPath(String processName) throws IOException
{
Runtime.getRuntime().exec(processName);
}
}
我得到的进程名,ID,seesionname,...但我需要一个过程的实际文件位置。 – Dineshkumar
@Dineshkumar:你在考虑windows 2003及以上版本吗? –
是的,尤其是windows8 – Dineshkumar