1

The following cmd is working fine for me

IF %var1% == value1 (
     echo true
) ELSE (
     echo false
)

What is the syntax for adding ORcondition inside the IF?

for example:

IF %var1% == value1 OR %var1% == value2(
     echo true
) ELSE (
     echo false
)
user829174
  • 6,132
  • 24
  • 75
  • 125

1 Answers1

0

Introducing the easiest and ugliest method :

set bool=false

if %var1% == value1 set bool=true
if %var1% == value2 set bool=true

if %bool% == true (echo true) else (echo false)

I spent years with batch programming, but I don't find such if.. or... statement, but it do have "and" condition. Like so :

if %var1% == value1 if %var1% == value2 (echo all is true) else (echo all is false)
Happy Face
  • 1,061
  • 7
  • 18
  • Sorry, the `and` version will echo *"all is false"* only if the first condition is evaluated to true and the second to false. – MC ND Oct 28 '15 at 08:53
  • @MCND Because that's an "and" condition, it doesn't work like "or" condition – Happy Face Oct 28 '15 at 08:58
  • 1
    Yes, it is an `and`, but you only get the echo when the first condition is true. If both conditions are false (or only the first one) you don't get the message – MC ND Oct 28 '15 at 09:00