Killing spawned external process with java

I have a java program that spawns an external process (IE browser, actually) using the Runtime exec() method. I use Process.waitFor() so the calling java will respond appropriately when the browser is closed. However, I would like to do the converse as well - kill the browser when the java exits. The destroy() method just kills the attached java thread and doesn't affect the browser; it just continues on asynchronously.

This would be simple to resolve on UNIX, but unfortunately we are running on Windows XP. I can't find any way to determine the PID (there could be more than one IE running and I only want to kill the one spawned by the java process) to kill the browser with a system call. Does anyone have any ideas on how to resolve this?

J

[771 byte] By [J33a] at [2007-11-26 14:30:50]
# 1
Java's child processes can be terminated from Java, but further generations that the native program spawns are out of reach.Short of renaming the native program that you're trying to kill to something unique and then killing that (using some os tool), I don't have a solution.
ChuckBinga at 2007-7-8 2:25:44 > top of Java-index,Java Essentials,Java Programming...
# 2
I have not tried it but MKS toolkit has a "kill" commandthat runs on DOS. You can use the MKS toolkit "ps" command to get the pid. Use pskill.exe to kill the service but it will only work on Win NT and XP. thanks.
Mudita at 2007-7-8 2:25:44 > top of Java-index,Java Essentials,Java Programming...
# 3

> I have not tried it but MKS toolkit has a "kill"

> command

> that runs on DOS. You can use the MKS toolkit "ps"

> command to get the pid. Use pskill.exe to kill the

> service but it will only work on Win NT and XP.

>thanks.

Yes, that works IF the PID is known; but how do you identify which of the multiple IE processes to kill?

ChuckBinga at 2007-7-8 2:25:44 > top of Java-index,Java Essentials,Java Programming...