Batchfile: What’s the best way to declare and use a boolean variable?

set "condition="

and

set "condition=y"

where y could be any string or numeric.

This allows if defined and if not defined both of which can be used within a block statement (a parenthesised sequence of statements) to interrogate the run-time status of the flag without needing enabledelayedexpansion


ie.

set "condition="
if defined condition (echo true) else (echo false)

set "condition=y"
if defined condition (echo true) else (echo false)

The first will echo false, the second true

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)