Code: Select all
@echo off
setlocal
::Define a Linefeed variable
set LF=^
::above 2 blank lines are critical - do not remove.
call :hexprint "0x07" rtnvar
REM FOR /L %%L IN (1,1,5) do echo %rtnvar%
FOR %%L IN (1 2 3 4 5) do echo %rtnvar%
REM pause
timeout /t 5 >nul
exit /b
:hexPrint string [rtnVar]
for /f eol^=^%LF%%LF%^ delims^= %%A in (
'forfiles /p "%~dp0." /m "%~nx0" /c "cmd /c echo(%~1"'
) do if "%~2" neq "" (set %~2=%%A) else echo(%%A
exit /b
EDIT: After further investigation, the FOR /L is actually executing all interations, it is just the echo of the BELL command does not echo out all iterations before the script closes.