Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run multiple commands in one line using cmd in windows 10

Tags:

cmd

as the title said I need to run exactly two commands in one line using cmd in windows 10. How is it possible?

like image 586
narcisse Avatar asked Oct 27 '25 14:10

narcisse


1 Answers

to run two commands use &. Both commands will be executed:

dir file.txt & echo done

Use && to execute the second command only if the first command was successful:

dir existentfile.txt && echo done

Use || to run the second command only if the first command failed:

dir nonexistentfile.txt || echo not found

You can combine:

dir questionablefile.txt && (echo file exists) || (echo file doesn't exist)
like image 66
Stephan Avatar answered Oct 29 '25 06:10

Stephan