How can I enter 2 commands on Windows command line?
Use &
.
From the documentation:
command1 & command2
: Use to separate multiple commands on one command line. Cmd.exe runs the first command, and then the second command.
command1 && command2
: Use to run the command following && only if the command preceding the symbol is successful. Cmd.exe runs the first command, and then runs the second command only if the first command completed successfully.
command1 || command2
: Use to run the command following || only if the command preceding || fails. Cmd.exe runs the first command, and then runs the second command only if the first command did not complete successfully (receives an error code greater than zero).
(command1 & command2)
: Use to group or nest multiple commands.
command1 parameter1;parameter2
: Use to separate command parameters.
&&
. The double ampersand actually performs error checking. If the commands to the left of the &&
don't return with the expected result, the commands on the right aren't executed.
cls && cd
If you want to run the commands on both sides of the &&
, use a single ampersand.
cls & cd