Rob
Rob

Reputation: 3459

Open command shell and execute command

I want to open a new shell and pass a command for it to execute in a single line of code from the windows cmd window. What is the easiest way to accomplish this?

For example I have a cmd shell and I want to execute:

C:\app\cmd.exe THEN "run_app.exe argument1"

Upvotes: 3

Views: 7058

Answers (1)

Thomas Weller
Thomas Weller

Reputation: 59289

cmd /c run_app.exe argument 

to close after executing or

cmd /k run_app.exe argument

to keep open after executing.

If in doubt, use full paths to your executable:

cmd /c c:\path\to\run_app.exe argument

To run several commands one after another, use chaining:

   cmd /k run_app.exe argument & second.exe & third.exe

Upvotes: 3

Related Questions