i am using Runtime.getRuntime().exec() command in Java to start a batch file which in turn starts another process for windows platform.
javaw.exe(Process1)
|___
Here is another option. Use this powershell script to execute your bat script. When you want to kill the tree, terminate your powershell script's process and it will execute taskkill on it's subprocess automatically. I have it calling taskkill twice because in some cases it doesn't take on the first try.
Param(
[string]$path
)
$p = [Diagnostics.Process]::Start("$path").Id
try {
while($true) {
sleep 100000
}
} finally {
taskkill /pid $p
taskkill /pid $p
}