So I want to check if "join.me" the program is running when my application opens.
That is the site to the download.
Process joinme = Runtime.getRuntime().exec("join.me");
Run Code Online (Sandbox Code Playgroud)
This doesn't seem to work.
Any idea?
Or I want to cycle through an array of processes to see what the "join.me" process is called.
Cheers.
您需要使用 Microsoft 的 OOTBtasklist.exe实用程序,该实用程序随 Windows 一起提供,可在C:\windows\system32\tasklist.exe. 以及以下行:
Process p = Runtime.getRuntime().exec("tasklist.exe");
Run Code Online (Sandbox Code Playgroud)
将执行它。然后你可以读取这个字符串,Scanner直到它有下一行。以下代码为您提供系统上运行的正在运行的程序(前台和后台应用程序)的列表:
public static void main(String[] args) throws IOException {
Process process = Runtime.getRuntime().exec("tasklist.exe");
Scanner scanner = new Scanner(new InputStreamReader(process.getInputStream()));
while (scanner.hasNext()) {
System.out.println(scanner.nextLine());
}
scanner.close();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6766 次 |
| 最近记录: |