Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch script command automatically stops batch script

I am experiencing a strange issue with the following batch script run via cmd.exe on Windows:

@echo off
gradle wrapper
gradlew build
pause

This batch script only ever executes the first command, i.e. gradle wrapper. After that, the batch script automatically terminates and the command gradlew build is never executed.

Is there any way I can force the batch script so that it cannot be stopped by gradle wrapper and continues its execution normally after gradle wrapper has been called?

like image 814
Andreas Avatar asked Apr 19 '17 15:04

Andreas


People also ask

How do I stop a batch file from closing automatically?

If you want the command prompt cmd widnow to stay open after executing the last command in batch file –you should write cmd /k command at the end of your batch file. This command will prevent the command prompt window from closing and you'll get the prompt back for giving more commands in the cmd window.

What is @echo off batch?

When echo is turned off, the command prompt doesn't appear in the Command Prompt window. To display the command prompt again, type echo on. To prevent all commands in a batch file (including the echo off command) from displaying on the screen, on the first line of the batch file type: Copy. @echo off.

How do I stop a script from running in command prompt?

Ctrl + C should stop a program running from the command prompt, similar to linux.

How do you end a batch script?

EXIT /B at the end of the batch file will stop execution of a batch file. use EXIT /B < exitcodes > at the end of the batch file to return custom return codes.


1 Answers

I have a feeling you may need to precede with call:

call gradle…
like image 51
Compo Avatar answered Oct 21 '22 06:10

Compo