Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch script stops executing after `gulp` process is complete, does not continue executing the rest of the script

I am attempting to write a simple batch file to build a gulp project and a maven project.

The current file follows:

cd C:\my\file\path
cmd /k gulp maven-deploy-local
cd C:\my\file\path\two\project-pom-parent
cmd /k mvn clean install -Dmaven.test.skip=true

Whenever I run this script, the command line stops after line 2 and before line 3. I end up looking at this line in cmd with a blinking cursor:

C:\my\file\path>

If I run the file without the cmd /k (as follows) then the prompt simply closes after line 2 and before line 3.

cd C:\my\file\path
gulp maven-deploy-local
cd C:\my\file\path\two\project-pom-parent
mvn clean install -Dmaven.test.skip=true

How can I modify the batch script so that it will continue and execute the commands on lines 3 and 4 and then remain open with the following line and blinking cursor?

C:\my\file\path\two\project-pom-parent>

I am operating on Windows 7 64-bit

like image 722
Blake Yarbrough Avatar asked Oct 19 '15 15:10

Blake Yarbrough


2 Answers

This task is specific enough to use this as well:

cd /d "C:\my\file\path"
cmd /c gulp maven-deploy-local
cd /d "C:\my\file\path\two\project-pom-parent"
cmd /k mvn clean install -Dmaven.test.skip=true

In essence the first cmd /k can be changed to cmd /c so it executes the command and continues to the last command, which leaves the prompt open.

like image 76
foxidrive Avatar answered Nov 03 '22 23:11

foxidrive


@ECHO OFF
IF NOT "%1"=="1" CMD /K ""%~f0" 1"
CD /d C:\my\file\path
CALL gulp maven-deploy-local
CD /d C:\my\file\path\two\project-pom-parent
CALL mvn clean install -Dmaven.test.skip=true
like image 45
Squashman Avatar answered Nov 04 '22 00:11

Squashman