enter image description hereI'm trying to SET one or two Variables in a for /f loop and use them outside the loop, but so far I have failed to do so, after hours of trying I finally gave up and ask for somebody to help me. I'm aware of the use of SETLOCAL ENABLEDELAYEDEXPANSION in a batch file but with or without using it it still does not work. The code so far is:
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
curl -s 192.168.1.68/cgi-bin/home | for /f "tokens=1,2,3" %%a in ('Grep -o -P "[0-9].{0,8}kWh.{0,0}"') do (
set VAR01=%%a
set VAR02=%%a
)
echo %VAR01%
echo !VAR01!
ENDLOCAL
RESULT on Console is:
(set VAR01=2.14 & set VAR02=2.14 )
ECHO is off.
ECHO is off.
The variable is SET in the loop but outside the loop it is not.