0

I am a beginner in winapi c++ on windows platform, i need to execute 3 exe files,i.e the installation programs, in one single program. i used shellexecute, exec v, system calls but all are exiting the program after the first program installation, please help me to solve this...

part of the code I used

ShellExecute( hwndDlg, "open", "calc.exe", NULL, NULL, SW_SHOWNORMAL );

status = execv(".\\InstallationFiles\\dotnetfx 35 SP1 Full.exe",child_args);

Thanking you in advance :)

hmjd
  • 120,187
  • 20
  • 207
  • 252
Paul
  • 39
  • 1
  • 9
  • I don't understand the problem. Is it that you want to execute the three processes one after the other. So, you execute one, wait for it finish, then execute the next, and so on. – David Heffernan Nov 30 '12 at 11:38
  • @DavidHeffernan yes, i have 3 exe files(requisites for another app), here I check the availability of these requisites, and if one is not available in the user system, the program should run the particular exe file, after its successful installation, it should check for further requisites. pls help – Paul Nov 30 '12 at 15:41
  • 1
    You want to call `CreateProcess` to start each task. Then call `WaitForSingleObject` passing the process handled returned by `CreateProcess`. That will then block until the task is complete. Then move on to the next task. – David Heffernan Nov 30 '12 at 15:43
  • @DavidHeffernan sorry for late reply, Thanks lot, but it works partially only, the second process is not waiting till the app 1 is installed completely, what to do. – Paul Dec 03 '12 at 08:45
  • 1
    No, WaitForSingleObject is known to work. You cannot expect us to explain what's up with your code when we cannot see it. Also do be aware that your question is terribly vague. You'll get much better help if you make more effort and ask better questions. – David Heffernan Dec 03 '12 at 08:58
  • @DavidHeffernan: yes thanks so much, it is working now, how can i make this installer silent, I hope you got my problem please help!!! – Paul Dec 04 '12 at 15:58

1 Answers1

0

Assuming you want to use WinAPI (one of your tags) you should use CreateProcess function. Here are some examples.

exec* family according to manual:

The exec family of functions replaces the current process image with a new process image. The functions described in this manual page are front-ends for the function execve(2). (See the manual page for execve for detailed information about the replacement of the current process.)

So if you want to stick to exec family functions you need to use some sort of fork() which brings some problems under windows, but here's an "linux-like" example.

Community
  • 1
  • 1
Vyktor
  • 20,559
  • 6
  • 64
  • 96
  • the commands you mentioned are for linux or unix based systems , its different for windows – Paul Nov 30 '12 at 15:47
  • 1
    @Paul Windows solution is `CreateProcess`, everything else is just a wrapper leading to that api call – Vyktor Nov 30 '12 at 15:50
  • @thanks Vyktor, but after the execution of one exe file does the rest of the codes run using create process. – Paul Nov 30 '12 at 16:22