Syntax
if command1 succeeds then execute command2 (IF)
command1 && command2
Execute command1 and then execute command2 (AND)
command1 & command2
Execute command2 only if command1 fails (OR)
command1 || command2
Success is defined as returning an %ERRORLEVEL% = 0
Care must be taken in using this syntax to read and SET variables as by default variables are expanded one line at a time.
Show a message if a file copy succeeds:
COPY H:\share\TNSnames.ora C:\Oracle\ && ECHO The Copy succeeded
Use conditional execution to test the success of several commands:
Dir C:\Test1 && Dir C:\Test2 || Echo One or more of the commands failed.
Note that in the above example, if the first DIR fails then the second will not be run at all.
“In modern democratic states, a privilege is conditional and granted only after birth. By contrast, a right is an inherent, irrevocable entitlement held by all citizens or all human beings from the moment of birth” ~ legal ethics
IF - Conditionally perform a command.
How-to: Command redirection