Q: How can I run two commands on one command line in cmd.exe?
Run multiple commands on a single line by using cmd.exe.
John Savill
December 27, 2011
1 Min Read
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 ||:
&&
||
Need more FAQs about System Center? Maybe virtualization? Or other Windows issues? See John Savill's FAQs for Windows!
About the Author
Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
You May Also Like