1

how can I get a call back when the process in the windows tasklist is killed using java?how can I monitor the event? i want to realize that if process is killed then start auto?

great thanks!

Mickel Lee
  • 473
  • 1
  • 5
  • 6

1 Answers1

1

Ok you can allocate a thread that every N seconds call the external process

tasklist /v 

maybe with a filter on your Window Title or program name.

To launch tasklist from java you can do

Process p = Runtime.getRuntime().exec("tasklist /v");
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));

and then read the BufferedReader and check for your process.

Remember to terminate every time the process in the right way.

dash1e
  • 7,677
  • 1
  • 30
  • 35
  • great thanks! how to terminate the process? now everytime it produce a tasklist.exe window os process. – Mickel Lee Apr 22 '12 at 10:21
  • There are many questions on this topic. For example read this question: http://stackoverflow.com/questions/5483830/process-waitfor-never-returns – dash1e Apr 22 '12 at 10:38
  • Read all this article: http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html – dash1e Apr 22 '12 at 11:32