0

I use Tomcat as a web server and Ant as a build tool and I need to make the process of deploying a little bit more faster, so that I can focus on the main thing - my program.

So I tried to create a small .bat file which contains all the operations I need to do for deployment to work on my machine. It includes tomcat server shutdown, ant buildfile, a directory deletion and copying of the newly created .war into the server directory.

All paths and commands are working without any problem when I type them on my command prompt, so the problem is not in the commands.

The prob is that the .bat program terminates after any of the tomcat or ant operations I use and doesn't complete the sequence. Probably because their nature is the same - executing in command prompt themselves. When I use 3 different .bat files each of them including only one tomcat/ant command, then all works fine.

Any ideas how to deal with it? Is it possible to automate the process in command prompt?

P.S. I forgot to mention (but I guess it's obvious) that I use Windows (7 in particular).

Galya
  • 6,294
  • 6
  • 27
  • 45

1 Answers1

1

Some applications you start from within the batch file are most likely not console applications, but Windows GUI applications. Or those applications are console applications which start itself other applications.

On starting a console application like findstr.exe the execution of the batch file is halted until the console application terminates. But starting a Windows GUI application results in execution of the application as a separate process and therefore the batch file execution immediately continues.

You have to run those applications which are executed automatically as separate process using

start "A title of your choice" /wait "Full path and name of application" "Parameter 1 for application" Parameter_2_for_application

For details on command start enter in a command prompt window either help start or start /?

See my answer on How to call a batch file in the parent folder of current batch file? with a comprehensive description on the various methods which exist to start or call a batch file or other applications from within a batch file.

Community
  • 1
  • 1
Mofi
  • 46,139
  • 17
  • 80
  • 143