How, from a cmd, start a new cmd instance and run a command within?
Create a batch file:
start cmd.exe /c <first command>
start cmd.exe /c <second command>
Run the batch file and it will open the two cmd windows and the batch file will exit.
Related videos on Youtube
WoJ
Updated on September 18, 2022Comments
-
WoJ over 1 year
I need to run two commands which never terminate. What I normally do is to
- start a
cmd
terminal and type in the first command - start another
cmd
terminal and type in the second command
I then have my two processes running in parallel.
I now would like to automate this by having one "startup" file which would lauch the two terminals above. It can be
cmd
or PowerShell based.Note 1: I tried to use
cmd
with/k
or/c
but this does not spawn a new terminal. Trying something likecmd /c cmd
ended up withInternal Error
output in the shell.Note 2: PowerShell has Background Jobs. The problem is that I want to have two separate shells I can monitor the output on (and eventually close the running process with
Ctrl-C
.Is there a way to achieve this in one file?
- start a
-
Bruno Bieri about 5 yearsWhat does the "/c" flag stand for?
-
Appleoddity about 5 years@BrunoBieri
/c
tellscmd
to run the command then exit. As opposed to/k
that tellscmd
to run the command and remain open - basically sit at the command prompt. If you need help with command line switches you can usecmd /?
.