I'm facing an issue i have with a FOR /F loop.
I'm executing the beneath code but the variable %IP% doesn't get populated.
I need to run the loop in a new window (minimized), so that the main program doesn't get delayed.
Code: Select all
START "stats" /MIN CMD.EXE /C FOR /F %%I in ('..\..\exe\curl.exe http://icanhazip.com') DO (@SET IP=%%I
echo Inside loop
ECHO %%I
ECHO %IP%
)
echo.
ECHO Outside loop
ECHO %IP%
echo.
PAUSE
EXIT
The problem is that the variable %IP% stays empty (it shows ECHO is off (UIT)) and only gets its value if i run the FOR loop in the same window as the main program (e.g. START "" /B or not using the START command at all), but then the remaining batch code will only be run when the FOR loop is finished, what i don't want.
Who has/knows the answer/solution?
Thanks.