Table of Contents

About

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

For a linux shell, see What are Control Operators in Bash?

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

Text - Ampersand Character (&)

Two Ampersand)

&&

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

||

. 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)