0

Can I use OR in an IF statement? Something like this:

if %str% equ 1 **OR** %str% equ 2 echo %str%
double-beep
  • 5,031
  • 17
  • 33
  • 41

1 Answers1

0

No, you cannot. You can do this with a goto:

if %str% equ 1 goto dosomething
if %str% equ 2 goto dosomething
goto aftersomething

:dosomething
  rem do something

:aftersomething

Or with a temporary variable:

set var=
if %str% equ 1 set var=1
if %str% equ 2 set var=1

if defined var (
  rem do something
)
Joey
  • 344,408
  • 85
  • 689
  • 683