Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute several batch commands in sequence

Tags:

I want to create a Windows XP batch script that sequentially performs something like the following:

@echo off :: build everything cd \workspace\project1 mvn clean install cd ..\project2 mvn clean install  :: run some java file cd \workspace\project3 java -jar somefile.jar 

When I create a Batch script like this (following these instructions), I still have the problem that the script stops doing something after the first

mvn clean install 

and then displays the command line. How can i execute all of these commands in sequence in one batch file?

I don't want to refer to other files, I want to do it in one file.

like image 861
ptikobj Avatar asked Jan 12 '11 20:01

ptikobj


People also ask

How do you run multiple commands in one line?

Running Multiple Commands as a Single Job We can start multiple commands as a single job through three steps: Combining the commands – We can use “;“, “&&“, or “||“ to concatenate our commands, depending on the requirement of conditional logic, for example: cmd1; cmd2 && cmd3 || cmd4.

Can you run 2 command prompts at once?

Click Start, type cmd, and press Enter to open a command prompt window. In the Windows taskbar, right-click the command prompt window icon and select Command Prompt. A second command prompt window is opened.

How do I run a command sequentially in Windows?

Instead of scheduling multiple Windows Tasks that may overlap, use the "start /wait" command a batch file (. bat) to automatically run multiple commands in sequential order.


1 Answers

I think your problem is that when you invoke mvn command you never go back to your script again.

Try using the call command e.g.:

call mvn clean install 

This will invoke mvn clean install command and then return back to your script.

When you simply invoke mvn without call you actually invoke mvn.bat file and pass control to it.

like image 183
Piotr Avatar answered Sep 22 '22 02:09

Piotr