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