
Executing multiple commands at command prompt in Windows:
Syntax:
command1 & command2
Example:
C:\ cd mydocs & dir *.doc
Conditional execution of chained commands:
1. command2 is executed only if command1 is executed successfully.
Syntax :
command1 && command2
Example:
dir *.doc && echo "Word Document Found"
2. command2 is executed only if command1 is not executed successfully.
Syntax:
command1 || command2
Example:
dir *.doc || copy d:\usefuldocs\*.doc
Grouping Command Chains:
Example:
(hostname & ver & vol) > info.txt
Above command will redirect all three command (hostname, ver, vol) output to info.txt. Grouping can also be used with conditional chained commands also, with a syntax like.
(command1 & command2) && (command3)
Warning:
If you do not enclose it using ( ) like in following example then only the last command (vol) output will be redirected to info.txt
hostname & ver & vol > info.txt





