new to batch. I’ve narrowed down my problem to how batch variables are evaluated I think.
setlocal enableextensions enabledelayedexpansion
set timelimit=30
for /F "USEBACKQ tokens=4,6,8" %%a in (`systeminfo ^| qgrep -e "System Up Time:"`) do set /A timepassed=%%a*24*60+%%b*60+%%c
IF "!timepassed!" LEQ "%timelimit%" (
echo %timelimit%
) ELSE (
echo !timepassed!
)
When run, I expect the batch to output !timepassed! (1250 currently) however, it always outputs %timelimit% (30), leading me to believe that the LEQ IF is being taken, which makes no sense to me.
as suggested, try the following changes in your code
set the variable value using
/Aoptionand compare the values with