Does there exist a way to pass control from one exe file to another such that when first exe ends the second one starts working ?
Asked
Active
Viewed 158 times
0
-
1@Tadman - I disagree, fork() is UNIX specific. Question is generic to c++, but not OS. In Windows apps, the technique must be done differently. – ryyker Apr 04 '14 at 18:44
-
1@Ryyker -- there is no C++ specific way -- the OP has not asked for a windows answer – Soren Apr 04 '14 at 18:46
-
@Soren - my point exactly. Nor has he/she asked for a UNIX solution, It is simply tagged C++ which does not use fork, exec etc. The reference given to support claim of duplicate question is unix specific, this question is not. – ryyker Apr 04 '14 at 18:49
-
@ryyker There is an [`exec` for Windows](http://msdn.microsoft.com/en-us/library/431x4c1w.aspx). – tadman Apr 04 '14 at 18:56
-
@Soren - Ummm, not very well ***[POSIX](http://en.wikipedia.org/wiki/POSIX)*** (read the section entitled ***POSIX for Windows*** – ryyker Apr 04 '14 at 18:56
-
@ryyker It's effectively a duplicate. A note could be added to the other answers to address how Windows uses ISO C++ names for the methods, `_exec` vs. `exec`. – tadman Apr 04 '14 at 19:01
-
@user3202180 - would you mind specifying which OS you are interested in? – ryyker Apr 04 '14 at 19:01
-
@tadman - No strong argument, you have a point. But there are probably 10,000 posts currently on SO _more_ qualified as "duplicates" than this one, many of which are not marked, just answered. (tongue in cheek) – ryyker Apr 04 '14 at 19:14
2 Answers
1
You have not specified OS, so here is a Windows specific answer...
Here are a few ways:
1) use a monitoring service application, that you write yourself to check status of PID/exenames. When the first app is no longer running, the service application can start the next app. In this way, you can daisy chain as many apps as you like together end to end, or simply bounce back and forth between app 1 & app 2. Service App
2) You can launch the second from a call in the first app just as it exits, and visa versa.
3) Use task scheduler.
There are many other ways, I personally recommend the first one as I have used it several times, and it works reliably.

ryyker
- 22,849
- 3
- 43
- 87