Reputation: 3641
I have a batch that is like this
@echo off
SET workspace="C:\yii2"
SET deploy_directory="C:\deployment"
SET source_file="C:\deployment\yii2"
SET destination_file="C:\deployment\deployment.zip"
cd "%source_file%"
start /wait update composer
start /wait xcopy "%workspace%" "%source_file%" /s /h /f
cd "%deploy_directory%"
start /wait zipjs.bat zipItem -source "%source_file%" -destination "%destination_file%" -keep yes -force no
pause
The bat file can anywhere be in the system.. So I write something like this.. Currently this is not working .. when it runs and change the directory the command prompt pops out and it does not process the next code.. Is there a silent way to change directory without interruption and will process the next command?
main goal is that to run composer update in the target path. Would appreciate also to explain what's happening here.
Pseudo:
1.) go to workspace path to update composer 2.) Copy workspace to a certain path with my zip bat 3.) change to that directory 4.) Run zipping bat
Edit: Added more steps
Upvotes: 0
Views: 36
Reputation: 13999
start
starts a new command window. You just want to change the working directory of the command window that is going to run update
. So don't use start for the cd
bit:
cd "%source_file%"
start /wait update composer
One reason to use start
is to run another batch file without terminating the current one. This works because the second batch file is run in a new command shell (and window). Usually, a better option is to use call
, which runs the second batch file in the current command shell / window but doesn't terminate the current shell. In your case, since update
is also a batch file, you can use call
. So your script now looks like this:
cd "%source_file%"
call update composer
Upvotes: 1