How, from a Cmd, Start a New Cmd Instance and Run a Command Within?

How, from a Cmd, Start a New Cmd Instance and Run a Command Within?

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 like cmd /c cmd ended up with Internal 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?

2 Answers

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.

2

I believe 'start cmd /c dir' is what you're looking for.
edit: Well, /k for short example like dir, but 'start' is the magic word you need.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sarah Jenkins
Author

Sarah Jenkins

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.