How to use "or" in a batch script

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Rileyh
Posts: 147
Joined: 01 Sep 2011 03:54
Location: Perth, Western Australia

How to use "or" in a batch script

#1 Post by Rileyh » 12 Sep 2011 21:38

Hi,
I was wondering if someone could tell me if you can use "or" or something like it in a batch file.
For example:
if /i _"%var%"=="(something)" OR "(something)" OR "(something)" (do whatever)

Is that an accepted command or is there a command that does the same thing that I could use.

Thanks,
Rileyh

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: How to use "or" in a batch script

#2 Post by Ed Dyreen » 13 Sep 2011 01:40

'

Code: Select all

@echo off &SetLocal EnableDelayedExpansion

set /a $error = 1
::
if 1 equ 0 (
  ::
  set /a $error = 0

) else if 2 equ 0 (
  ::
  set /a $error = 0

) else if 0 equ 0 (
  ::
  set /a $error = 0
)
::
if !$error! equ 0 (
  ::
  echo. 1 equ 0 OR 2 equ 0 OR 0 equ 0 : do whatever:^)
)

EndLocal

pause
exit /b 0

Post Reply