0

I have a .bat script that launches a java process "java -jar ..." and after that I have two process in Windows, the original from where the bat is running (a cmd process) and a java process.

If we kill the java process the control returns to bat script and it finishes, but if we kill the cmd process the java process continues running. Does exist a way to propagates the kill from the bat script to the others processes opened from it ?

Luciano
  • 2,695
  • 6
  • 38
  • 53

1 Answers1

0

use START to launch a process without waiting for it to return, that way your batch can finish as needed.

START "WindowTitle" java -jar ...

you actually have to tell it to wait if you need the process to finish first

START "WindowTitle" /WAIT java -jar ...

Your Java program would have to look for the process that launched it to stop if its launcher program was killed

SeanC
  • 15,695
  • 5
  • 45
  • 66
  • Thanks by the answer. But Almost there... Unfortunately this approach "moves" the console output from where the bat is run to a new console window so, as I'm using Visual Studio to start the bat script and it captures the output and shows it in a internal console, the output isn't shown anymore in Visual Studio console. – Luciano Oct 03 '12 at 20:05