We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Function to execute applications

Yinteo
Yinteo asked
on
Medium Priority
248 Views
Last Modified: 2010-04-02
Hi everyone,

I need to write an application to run a list of other applications. May I know if anybody is aware of a win32 api or any C functions which can allow me to execute an application and then wait for it to complete before returning the control to my main application(to carry on with the other applications. If there is, how can I use it?


Thank You
Yinteo
Comment
Watch Question

ozo
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2015

Commented:
#include <stdlib.h>
int system (const char *string);

Commented:
ozo forgot to mention you pass a strng with the path and name of the executable you want to run as a parameter to this command.  Like system("C:\TEST\MYAPP.EXE");

Commented:
You also might want to consider the spawn() functions (there is no "spawn" function there are about 10 of them that begin with "spawn" and have 1 or 2 letters at the end.)  These functions allow you to run a process and to specify its environment and parameters in a variety of ways.  With these functions you can  a mode of _P_WAIT to have your process wait until the other process finishes befure spawn returns.  Or you can specify _P_NOWAIT to have spawn return as soon as the other process starts.

Commented:
There are several ways to run a program. Besides the system and spawn, there are still exec and createprocess. You can see the online help to find which one is most fit for youe need.

Commented:
And ShellExecute() as well.

Commented:
Ha!  at last, a chance to pick fault with nietod's Godlike, instant, and invariably correct answers  :)  !  ("C:\\TEST\\MAYAPP.EXE")


Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Commented:
warmcat, that is still wrong.  the application name is "myapp" not "mayapp"!  :-)

Commented:
Why are sticking the typing errors...
Do you think vanille should post his comments as an answer? All of us have been polite to each other for so long time. Each of us has given meaningful advices.

Commented:
agreed.  Ozo was here first and gave a solution that should work.  But it will be up to Yinteo to decide who gets the points.

Commented:
Or share the points by post other questions with smaller points indicating to whom. Reject this answer and wait 21 days then get the 200 back.

Author

Commented:
Thanks!

Commented:
Yinteo you graded vanille's answer.  Is that really expert you felt contribute the most?  that answer had already been provided by trestan and I suspect it is not the one you want anyways.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.