How do I run two commands in one line in Windows CMD?

 

In the Windows Command Prompt (CMD), you can run two commands in one line by separating them with the & character. This allows you to execute multiple commands sequentially on a single line. Here's how you can do it:

sh
command1 & command2

Here's an example:

sh
echo "Hello, World!" & dir

In this example, the echo command is used to print "Hello, World!" to the console, and the dir command is used to list the contents of the current directory. Both commands are executed one after the other on the same line.

You can use this approach to run any combination of commands in a single line in the Windows Command Prompt. Just separate the commands with the & character.

Comments