Andre
Andre

Reputation: 661

CMD lines work fine but not in .bat file, it just instantly closes?

I tested the folowing lines in cmd ("ctrl + r" ---> "cmd") and it works fine , but it doensn't work in .bat file , cmd comes up and then instantly closes

Here is my code

D:
cd D:\Java\Projects\Jasper\random-jasper-lib\
mvn clean install
cd D:\Java\Projects\Jasper\random-jasper\
mvn clean install
pause

How can I get the window to Stay open ?? (preferably even if there are errors)

Upvotes: 1

Views: 2490

Answers (3)

user330315
user330315

Reputation:

mvn is a batch file.

If you call one batchfile from another, you have to use call otherwise the calling batch file will be terminated:

Using the /d for the cd command is also a good idea.

cd /d D:\Java\Projects\Jasper\random-jasper-lib\
call mvn clean install
cd /d D:\Java\Projects\Jasper\random-jasper\
call mvn clean install
pause

Upvotes: 3

Endoro
Endoro

Reputation: 37569

Why not with the pause command? -alternatively put cmd /k on the very last line of your script.

cd /d "D:\Java\Projects\Jasper\random-jasper-lib"
start /b "" "mvn" clean install
cd /d "D:\Java\Projects\Jasper\random-jasper"
start /b "" "mvn" clean install
cmd /k

Upvotes: 2

Snowman25
Snowman25

Reputation: 1

try it like this:

PUSHD D:\Java\Projects\Jasper\random-jasper-lib\
mvn clean install
POPD
PUSHD D:\Java\Projects\Jasper\random-jasper\
mvn clean install
POPD
PAUSE

save as test.bat and execute it from cmd. that way it won't close the shell and you can see the errormessages

Upvotes: 0

Related Questions