How do I pass multiple commands to START in Windows Command Line?
How do I pass multiple commands to start
?
I tried
start "window title" echo 1 && echo 2
But, predictably, start only gets "echo 1" and thus "1" is echoed in the new window, and "2" is echoed in the first window.
Is there some way to "escape" the &&
operator, or another way to pass multiple commands into start
so they run successively in the new window?
Solution 1:
How do I pass multiple commands to start?
You need to use the cmd /k
option and also quote the command
you are running.
The following command will work:
start "window title" cmd /k "echo 1 && echo 2"
where:
Options
/C Run Command and then terminate
/K Run Command and then return to the CMD prompt.
This is useful for testing, to examine variables
Command : The command, program or batch script to be run.
This can even be several commands separated with '&'
(the whole should also be surrounded by "quotes")
Source: CMD.exe (Command Shell) - Windows CMD - SS64.com
Further Reading
- An A-Z Index of the Windows CMD command line | SS64.com
- Windows CMD Commands (categorized) - Windows CMD - SS64.com
- CMD.exe (Command Shell) - Windows CMD - SS64.com - Start a new CMD shell and (optionally) run a command/executable program.
Solution 2:
Another method is to escape the &
with ^
.
start "window title" echo 1 ^&^& echo 2