Using conditional command execution

[Autolink] Menu

For simple tasks you can use the unconditional and the conditional command execution of the CMD.EXE.

┌──────────────────────────────┬──────────────────────────────┐
│Command separator             │Meaning                       │
├──────────────────────────────┼──────────────────────────────┤
│command1 & command2           │Execute command1; execute     │
│                              │command2 regardless of the    │
│                              │exit code of command1         │
├──────────────────────────────┼──────────────────────────────┤
│command1 && command2          │Execute command1; execute     │
│                              │command2 only if the exit code│
│                              │of command1 is 0.             │
├──────────────────────────────┼──────────────────────────────┤
│command1 | command2           │Execute command1 and command2;│
│                              │pipe STDOUT of command1 into  │
│                              │STDIN of command2 (see Using  │
│                              │PIPEs and Pipes & Errorlevel) │
├──────────────────────────────┼──────────────────────────────┤
│command1 || command2          │Execute command1; execute     │
│                              │command2 only if the exit code│
│                              │of command1 is NOT 0          │
└──────────────────────────────┴──────────────────────────────┘

Note: command1 and command1 can be an internal or external OS/2 command or two or more commands separated with one of the separators. Using parenthesis to group the commands is also possible. (constructions like

 
(c1 && c2) || ( c3 && c4 || c5)

are possible)