lundi 18 juillet 2016

Can't set already set variable batch

Ditto. Here's my code:

set var1=Yes
echo.
echo var1 = %var1%
set condition1=true
echo.
echo condition1 = %condition1%
IF %condition1%==true set %var1%=No
echo.
echo Comparison done with an ERRORLEVEL of %ERRORLEVEL%, var1 got set to %var1%
PAUSE

The code prints out:

var1 = Yes
condition1 = true
Comparison done with an ERRORLEVEL of 0, var1 got set to Yes

which suggests that my code doesn't have a bug, but is actually part of the logic programmed into Batch.

Is there some other way that I can create a bodge to work around the issue, is it because I run the programs off of a DVD, or is there perhaps a fix? Thanks in advance!

(P.S. I also tried the code with Delayed Expansion, but that didn't work either.)

Aucun commentaire:

Enregistrer un commentaire