Windows 批处理脚本何时不执行除错误以外的所有命令

Windows 批处理脚本何时不执行除错误以外的所有命令,windows,batch-file,cmd,Windows,Batch File,Cmd,我编写了一个批处理脚本,成功地执行了其他人的命令,但我随后的命令没有继续。为什么? 我的剧本: 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=releas

我编写了一个批处理脚本,成功地执行了其他人的命令,但我随后的命令没有继续。为什么? 我的剧本:

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
这个图像是运行的结果,正如您在这里看到的,执行是成功的,但是我后面的脚本没有输出,也没有执行

当您像以前那样执行另一个脚本时,不会“返回”到原始脚本。解析器只是点击“脚本末尾”并停止处理。使用
call
来“执行并返回”:
call。\jam Editor-sCONFIG=release
我建议不要在批处理文件中仅使用
exit
,使用
exit/B
goto:EOF
退出当前批处理文件的处理,而不是使用选项
/C
独立于启动时退出Windows command processor,如双击批处理文件,或使用选项
/K
从批处理文件中打开命令提示窗口执行并独立于调用层次结构<代码>退出而不选择
/B
在批处理文件中通常不好,尤其是在另一批处理文件上或从另一批处理文件调用批处理文件时。@Stephan这对我帮助很大!