Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open command shell and execute command

Tags:

windows

cmd

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"
like image 613
Rob Avatar asked Feb 21 '26 22:02

Rob


1 Answers

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
like image 87
Thomas Weller Avatar answered Feb 23 '26 11:02

Thomas Weller