0

I am running two batch Java classes fron windows batch file in a sequence. I want to give an option to exit after the first class is run; after the first pause statement.

How do I use jump to terminate the program if the user wants to close it without using the close button on GUI?

Also, can PAUSE e customised to change its default message?

@ECHO off
color 0E


ECHO Running prog.....
ECHO Step 1 commences....

java -cp D:\proj\bin;D:\proj\mysql-connector-java-5.1.12-bin.jar com.Class1

ECHO Please ensure modem is on and press any key!
ECHO Step 2 commences....

PAUSE

:: Give option to exit

java -cp D:\proj\bin com.Class

echo Completed program.....

PAUSE
1
  • 1
    You can use >nul after the pause so pause>nul to make it not print press any key to continue . . . Commented Feb 5, 2014 at 16:31

1 Answer 1

1

To customize PAUSE's message, you can ECHO the message you wish to display, then pipe PAUSE's output to NUL:

echo Please press any key on your keyboard to continue with this program
pause>nul

To exit your batch file between the two Java program execution, you can do the following:

@ECHO off
color 0E

ECHO Running prog.....
ECHO Step 1 commences....

java -cp D:\proj\bin;D:\proj\mysql-connector-java-5.1.12-bin.jar com.Class1

SET /P __ANSWER_=Do you wish to continue? (y/n)
IF /I %__ANSWER_% EQU N GOTO :EOF

ECHO Please ensure modem is on and press any key!
ECHO Step 2 commences....

PAUSE

:: Give option to exit

java -cp D:\proj\bin com.Class

echo Completed program.....

PAUSE

You can replace the GOTO :EOF command with a GOTO to a specific label if you with to display something to the user before ending the batch file execution.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.