import java.util.Scanner; public class Test { public static void main(final String[] args) throws Throwable { final String command = "firefox.exe"; final String cmd1 = "wmic process where name='" + command + "' get description,commandLine"; final Process p = Runtime.getRuntime().exec(cmd1); final Scanner sc = new Scanner(p.getErrorStream()); while (sc.hasNextLine()) System.out.println(sc.nextLine()); sc.close(); } }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionString cmd= "cmd /c wmic Process where name " + command + " get processid";
String cmd="cmd /c wmic.exe process where name="+command+"get ProcessID";