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

半世苍凉 提交于 2019-12-10 12:58:05

问题


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


回答1:


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.




回答2:


@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


来源:https://stackoverflow.com/questions/33218246/batch-script-stops-executing-after-gulp-process-is-complete-does-not-continue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!