As Mike Nakis said, it's the batch file sleep
.
It's not important if sleep.bat
contains @echo off
or not.
The problem is that starting a batch file from another batch file transfers the control to the new batch file but doesn't return to the caller.
But in your case you have a FOR-loop
which is completly cached by the cmd.exe.
That's the cause why the first batch doesn't stops immediately.
But when the second loop runs, the cmd.exe has leaved the batch-file-mode
and is now in the cmd-line-mode
.
You could control this by adding an echo line.
@echo off
set "world=" -- unset the world variable
for /L %%n in (1 1 3) do @(
call echo Hello %%n %%world%%
sleep.bat 1
)
The output will be
1 Hello
2 Hello %world%
3 Hello %world%
That's because the cmd-line-mode doesn't remove percent expansions when the variable is unset.
The CALL sleep.bat
solves the problem, as then control simply returns to the caller, as expected.