0

In windows OS. using tasklist ( getting list of current open process ) i have collected list of running process. But how to get actual path of executable file of that process [FILE LOCATION]?

Is there any way to find recently used process from java?

Community
  • 1
  • 1
Dineshkumar
  • 4,165
  • 5
  • 29
  • 43

1 Answers1

0

do you mean something like this

    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);
         }
        }