0

I wrote a batch script that successfully executed someone else's command, but my subsequent command did not continue. Why? My script:

cd /d "%~dp0"
echo %cd%
set Param=%1%
set resultDir=..\build\UnityXXXXX-%Param%-Mac

echo start build Editor
: This line is executing someone else's script!!!!!!!!
.\jam Editor -sCONFIG=release
: The previous script finishes executing without any error, but even then, the later scripts will not continue to execute!!!!!!!!

echo start copy to build dir
if not exist .\build\WindowsEditor\Unity.exe (
    echo the Unity is not build, build it first.
    pause
    exit
)
if exist %resultDir% rd /s /q %resultDir%
md %resultDir%
xcopy /s ..\UnityXXXXX\* %resultDir%\
xcopy .\build\WindowsEditor\Unity.exe %resultDir%\Contents\Unity.exe*

echo finish
pause

This image is the result of the run, as you can see here, the execution was successful, but the echo of my later script has no output and no execution enter image description here

  • 4
    When you execute another script like you did, there is no "return" to the original script. The parser just hits the "End of Script" and stops processing. Use `call` to "execute and return": `call .\jam Editor -sCONFIG=release` – Stephan Aug 29 '20 at 07:43
  • 1
    I recommend to use never just `exit` in a batch file, use instead `exit /B` or `goto :EOF` to exit just processing of current batch file instead of exiting Windows command processor independent on being started with option `/C` as on double clicking on a batch file or with option `/K` as on opening a command prompt window from within the batch file is executed and independent on calling hierarchy. `exit` without option `/B` is usually not good in a batch file, especially on [debugging a batch file](https://stackoverflow.com/a/42448601/3074564) or calling a batch file from another batch file. – Mofi Aug 30 '20 at 08:45
  • @Stephan This helps me a lot! – AndLightLight Aug 31 '20 at 02:58

0 Answers0