how to chain the START command in cmd?

Viewed 2966

My goal is to be able to chain START commands in a single cmd line.

Lets say I have a cmd window (lets call it starter). With a single line I want to start a new cmd window (lets call it cmd1) that will echo 1 and start another cmd window (lets call it cmd2) that will echo 2 and wait (with pause), after cmd1 called cmd2 (without waiting for it to finish) it will wait as well (with pause), after starter called cmd1 (without waiting for it to finish) it will close (or do nothing)

In the end I should end up with 2 cmd windows (cmd1 with "1" printed, cmd2 with 2 printed) and both are waiting for ENTER.

Running scheme:

--- Starter
    +--- Start cmd1 (Non-blocking)
    |    +--- Start cmd2 (Non-blocking)
    |    |    +--- Echo 2
    |    |    \--- Pause (Blocking cmd2)
    |    +--- Echo 1
    |    \--- Pause (Blocking cmd1)
    \---Do nothing (Starter, Incase running from bat file starter will exit)

I wrote this cmd line in a bat file:

title starter 
start cmd.exe /c start cmd.exe /c "echo 2 & pause" & echo 1 & pause
                       \----------cmd2-----------/
      \---------------------------cmd1----------------------------/

(the "title starter" is just for understanding which window is opened and should not be included in the final line)

with that cmd line, starter is the one that prints 2 and waits, and cmd1 just exits after calling cmd2.

The running scheme of that line:

--- Starter
    +--- Start cmd1 (Non-blocking)
    |    \--- Start cmd2 (Non-blocking)
    |         +--- Echo 2
    |         \--- Pause (Blocking cmd2)
    +--- Echo 1
    +--- Pause (Blocking Starter)
    \---Do nothing (Starter, Incase running from bat file starter will exit)

I tried some other variations of this line with no success.

title starter 
start "cmd.exe /c start cmd.exe /c "echo 2 & pause" & echo 1 & pause"
start cmd.exe /c "start cmd.exe /c "echo 2 & pause" & echo 1 & pause"
start cmd.exe /c "start cmd.exe /c ""echo 2 & pause"" & echo 1 & pause"

(important to note that I can open the 2 cmds (cmd1, cmd2) from the first cmd (starter) and the result of this will be the final result of my wanted running scheme, but it is important that cmd1 will be the one that creates cmd2)

So, does anyone know how may I achieve the running scheme that I want?

2 Answers
Related