Skip navigation

Q: How can I run two commands on one command line in cmd.exe?

A: It's actually very easy to run multiple commands on a single line by using cmd.exe: Just add the & character between the commands, like this:

cd data & notepad file.txt

This command changes the folder to data, then opens the file named file.txt.

You can use more advanced combinations that run the second command only if the first was successful, by using && instead of just a single &.

You can also run only the second command if the first command has an error by using ||. Below is an example of using && and ||:

<first command> && <second command runs if first is successful>

<first command> || <second command runs if first has an error>


Need more FAQs about System Center? Maybe virtualization? Or other Windows issues? See John Savill's FAQs for Windows!

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish