user701254
user701254

Reputation: 3953

How to prevent a bat file exiting early?

I'm running a maven plugin (this is just a new process) as part of a bat file.The plugin command causes the bat file to exit so the subsequent commands do not run. Is there a command or some other way to prevent the bat file quitting too soon ?

Here is the bat file :

ECHO Updating Version
mvn versions:set -DnewVersion=1.2

ECHO this echo does not occur

Perhaps I could use the 'call' command as referenced in How do you stop a Windows Batch file from exiting early? but I would like to run all of the code within one bat file.

Upvotes: 6

Views: 5149

Answers (3)

RonaldBarzell
RonaldBarzell

Reputation: 3830

If mvn is a batch file, then you need to precede it with a call, or else it will terminate on that line.

Upvotes: 8

ElektroStudios
ElektroStudios

Reputation: 20494

Use the PAUSE command.

Pause /?

Example:

@Echo off
Echo hello world
Pause >NUL
exit

Upvotes: -1

seesharper
seesharper

Reputation: 147

I would use:

set /p v=Press enter to exit

At the end of your program. This will wait for the user to interact before exiting.

Upvotes: 0

Related Questions