The maximum "allowed" '@' characters on my Win XP home (SP3, 32bit) is 2325 (no matter if piped or not; on my win8 the maximum is 4298 - both piped and 'normal'), so this is working:
Code: Select all
@echo off
setlocal enableExtensions enableDelayedExpansion
:: create 4096 '@' characters
set "test=@@@@"
set test=!test:@=%test:@=@@%!
set test=!test:@=%test:@=@@@@%!
%test:~-2325%echo a
endlocal
Windows XP:
But if i manually start this batch file ("test1.bat") 9 times from my desktop path ("C:\Dokumente und Einstellungen\...\Desktop>") then the cmd also closes.
If create a "z"-drive (using "subst z: .") i am able to start this batch 14 times.
Windows 8 - 32 bit:
started it 100 times - seems it runs always.
Windows XP:
The file is also proecessed completely if there are more '@' characters, but it is closed at the end (try any batch source with "pause" as a last line, inclusing goto, call and run executables):
Code: Select all
@echo off
setlocal enableExtensions enableDelayedExpansion
:: create 4096 '@' characters
set "test=@@@@"
set test=!test:@=%test:@=@@%!
set test=!test:@=%test:@=@@@@%!
%test:~-2326%echo a
endlocal
echo internal command
cmd /q /C echo external command
call :function
goto :label
:function
echo function
goto :eof
:label
echo Good bye!
pause
One could also 'rescue' the shell 'influenced' with up to 2376 '@' characters with 2 lines containing exactly 2325 '@' characters (all other tested amount failed at least on my system):
Code: Select all
@echo off
setlocal enableExtensions enableDelayedExpansion
:: create 4096 '@' characters
set "test=@@@@"
set test=!test:@=%test:@=@@%!
set test=!test:@=%test:@=@@@@%!
%test:~-2376%echo a
%test:~-2325%echo a
%test:~-2325%echo a
endlocal
penpen
Edit: I have minimized the line length.
Edit2: Added more information.