What's the best way to declare and use a boolean variable in Batch files? This is what I'm doing now:
set "condition=true"
:: Some code that may change the condition
if %condition% == true (
:: Some work
)
Is there a better, more "formal" way to do this? (e.g. In Bash you can just do if $condition
since true
and false
are commands of their own.)
I'm sticking with my original answer for the time being:
set "condition=true"
:: Some code...
if "%condition%" == "true" (
%= Do something... =%
)
If anyone knows of a better way to do this, please answer this question and I'll gladly accept your answer.