zeja
Erfahrenes Mitglied
Folgendes habe ich mal bei mir getestet:
Java:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class ProcessView {
public static String getProcessTable(String processToFind) {
try {
Process p = Runtime.getRuntime( ).exec("cmd /c tasklist /v");
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream( )));
String line = null;
while ((line = in.readLine( )) != null) {
if (line.trim( ).contains(processToFind)) {
return line;
}
// else{
// System.out.println(line);
// }
}
in.close( );
}
catch (IOException e) {
e.printStackTrace( );
}
return processToFind + " not found";
}
public static void main(String[] args) {
System.out.println(getProcessTable("svchost.exe"));
}
}