Windows 10 CMD.EXE - 'Terminate batch job (Y/N)?', replying yes detach java call inside

  • Thread starter Thread starter ArfyFR
  • Start date Start date
A

ArfyFR

Hi,


I use some batch files for exemple to launch Jetty. Example

@echo off

set
CUR=%~dp0


...

:check_JETTY_BASE
if exist "%JETTY_BASE%" goto ok_JETTY_BASE
echo Error: JETTY_BASE set to "%JETTY_BASE%" but directory does not exist
goto error



:ok_JETTY_BASE



cd
%JETTY_BASE%
java -jar %JETTY_HOME%/start.jar %JETTY_OPTIONS% %JETTY_STOP_OPTIONS% --module=ext jetty-started.xml
pause
goto end



:error
cd
/D "%CUR%"
exit /b 1



:end
cd
/D "%CUR%"



All is launched well.

⇒ Jetty is well launched and serve requests.

⇒ Batch launch stays as expected before the pause cmd.

⇒ if I use the "Jetty STOP" command, no problem, "pause is called"


My question is about the CTRL-C, why does it not "stop" the java call, but the CMD.EXE batch?

I see then

'Terminate batch job (Y/N)?'

  • if I do CTRL-C twice, the Jetty (java) stays in memory *sigh*
  • if I reply "Yes" same problem *sigh*
  • if I reply "No" ⇒ ok "pause is called"


Does it exist a way inside .BAT to forward the CTRL-C to here the


java -jar %JETTY_HOME%/start.jar %JETTY_OPTIONS% %JETTY_STOP_OPTIONS% --module=ext jetty-started.xml


?

Continue reading...
 
Back
Top