DOS - (Control Operators | Command Separator)

About

Dos supports the following control operator in order to control or separate command instruction.

For a linux shell, see Shell - Control Operators

Cheatsheet

Operator Description
& all commands run serially without error checking
&& execute the next command only if the previous command is successful
|| execute the next command only executed only if the previous command has failed
() group commands

List

Ampersand

Two Ampersand)

<wrap box>&&</note> The command following && is executed only if the first command is successful. This will work only with a command used before && that returns an exit code of 0 (zero).

echo 1 && echo 2
1
2

One Ampersand

& error checking is not performed and all commands run serially.

badcommand 2>null & echo 1 & echo 2
1
2

where:

OR

The OR control operator <wrap box>||</note>. The command following && is executed only if the first command has failed. This will work only with a command used before && that returns an exit code that is not `0' (zero).

echo 1 || echo 2
1

()

Group command

(echo 1 && echo 2)

Powered by ComboStrap