how to delete a group of process with same name in java

is there a way to delete a bunch of processes with the same name?  i know you can do this taskkill.exe /F /IM iedriverserver64.exe /T, just not sure how to do it programmatically.  thanks.
Who is Participating?
StillUnAwareConnect With a Mentor Commented:
You could always call the same command you wrote from java program using java.lang.Runtine.exec or java.lang.ProcessBuilder.


class UsingProcessBuilder {
  public static void main(String[] s) throws Exception {
    ProcessBuilder pb = new ProcessBuilder("cmd", "/c", "taskkill.exe /F /IM iedriverserver64.exe /T");
      Process p = pb.start();
      System.out.println("Exit value: " + p.waitFor());
      System.out.print("Output: ");
      InputStream is = p.getInputStream();
      while(is.available() > 0) {
      System.out.print("\nError: ");
      is = p.getErrorStream();
      while(is.available() > 0) {
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.