I'm trying to write a Windows cmd script to perform several tasks in series. However, it always stops after the first command in the script.
The command it stops after is a maven build (not sure if that's relevant).
How do I make it carry on and run each task in turn please?
Installing any software or configuring the registry etc is completely out of the question - it has to work on a vanilla Windows XP installation I'm afraid.
Ideally I'd like the script to abort if any of the commands failed, but that's a "nice to have", not essential.
Thanks.
When you call another .bat file, I think you need "call" in front of the call:
Using double ampersands will run the second command, only if the first one succeeds:
Where as, using only one ampersand will attempt to run both commands, even if the first fails:
If you are running in Windows you can use the following command.
Drive:
I have just been doing the exact same(ish) task of creating a batch script to run maven test scripts. The problem is that calling maven scrips with mvn clean install ... is itself a script and so needs to be done with call mvn clean install.
Code that will work
Note rather the use of call. This will allow the use of consecutive maven scripts in the batch file.
You can use the && symbol between commands to execute the second command only if the first succeeds. More info here http://commandwindows.com/command1.htm
Note that you don't need semicolons in batch files. And the reason why you need to use call is that mvn itself is a batch file and batch files need to call each other with call, otherwise control does not return to the caller.