You have trailing spaces after the 2
, so compare if "2 " == "2"
(not equal).
To avoid this use the following code:
set "VARY=before" if "!VARY!" == "before" ( set "VARY=2" if "!VARY!"=="2" echo If you see this, yes echo !VARY! )
.. and if you set numbers, you can also use "set /a":
set "VARY=before" if "!VARY!" == "before" ( set /a VARY=2 if "!VARY!"=="2" echo If you see this, yes echo !VARY! )