IF Conditionally perform a command
IF DEFINED SIGN (
runtest.exe --redirect -l %NAME%
) ELSE (
runtest.exe -l %NAME%
)
or shortly
IF DEFINED SIGN (runtest.exe --redirect -l %NAME%) ELSE (runtest.exe -l %NAME%)
Valid syntax:
- all
), ELSE and ( must be on an only line as follows: ) ELSE (
Note:
if DEFINED will return true if the variable contains any value (even if the value is just a space).
According to above predicate, IF DEFINED SIGN condition seems to be equivalent to reformulated test if NOT "%SIGN%"=="" but it is valid in batch only, where %undefined_variable% results to an empty string:
if NOT "%SIGN%"=="" (runtest.exe --redirect -l %NAME%) ELSE (runtest.exe -l %NAME%)
Otherwise, in pure CLI, %undefined_variable% results to %undefined_variable%
Proof:
==>type uv.bat
@echo undefined_variable="%undefined_variable%"
==>uv.bat
undefined_variable=""
==>echo undefined_variable="%undefined_variable%"
undefined_variable="%undefined_variable%"
==>
if existschecks for files. for variables do:if defined sign(without the percent-signs