Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

run 2 or more cmd command using system() in C++ [duplicate]

Tags:

c++

cmd

I want to do two steps in my c++ program using system().

  1. open the folder system("cd /d ...")
  2. run another program.exe

However, it seems like when I run step2, the folder opened in step1 is already closed. What can I do to make sure that the folder won't be closed, so that I can use another cmd call to run .exe?

Thanks!

like image 943
user4029119 Avatar asked Oct 16 '14 09:10

user4029119


1 Answers

you can use

system("command1; command2; command3");

or

system("command1 && command2 && command3");

Refer To The following link: Using a Single system() Call to Execute Multiple Commands in C

like image 74
OshoParth Avatar answered Sep 28 '22 17:09

OshoParth