简体   繁体   中英

Batch file ECHO not working after PUSHD command

I have a .bat (batch) file with the following line, the last line echo isn't run.

set outputfile=C:\DeployLog-label-test.txt
echo ----- Start File 1 of 1 ----- >> %outputfile%
pushd C:\src&ant -Dinifile=C:\repo\IR.ini -Dfilelist="label.xml" >> %outputfile% 2>&1&popd
echo ----- End File 1 of 1 ----- >> %outputfile%

Is it because of pushd command? Please help. Thanks.

No, in this case the "problem" is that ant is a batch file, and if from inside a batch file (your batch file) you call another batch file, execution flow is transfered to the called batch and it does not return to the caller. UNLESS the call of the second batch file is done with call command. So, your code should be

pushd C:\src&call ant -Dinifile=C:\repo\IR.ini -Dfilelist="label.xml" >> %outputfile% 2>&1&popd

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM