Существуют некоторые немедленные остановки ошибок.
Но в вашем особом случае причина неизвестна, как и код.
rem error1 - Invalid % Expansion
rem %~
rem error2 - call REM /?
set "switch=/?"
call rem %%switch%%
rem error3 - stackoverflow
:stack
call :stack
rem error4 - call caret crash only with Vista
set "caret=^"
call echo %%caret%%
rem error5 - Long expansion
rem shows that expansion of % in a line is before the rem ignores the rest of the line
rem The expansion results in a very long line with 10000 characters, the batch stops immediatly
setlocal EnableDelayedExpansion
set "longStr=."
for /L %%c in (1,1,13) DO set longStr=!longStr:~0,2500!!longStr:~0,2500!
rem Now we heave a string with 5000 characters, and build a rem line with 2 times 5000 = 10000 characters
rem The next line crashes the batch file
rem tokenOne %longStr% %longStr%
(
ENDLOCAL
goto :eof
)
rem error 6 - %%var<LF> error, crashes only sometimes
set critical_content=hello%%~^
echo $
for %%a in (1 ) do (
for %%x in (4) do (
rem #%critical_content%#
)
)