Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

Function to execute applications

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
0
Yinteo
Asked:
Yinteo
1 Solution
 
ozoCommented:
#include <stdlib.h>
int system (const char *string);
0
 
nietodCommented:
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");
0
 
nietodCommented:
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.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
trestanCommented:
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.
0
 
nietodCommented:
And ShellExecute() as well.
0
 
warmcatCommented:
Ha!  at last, a chance to pick fault with nietod's Godlike, instant, and invariably correct answers  :)  !  ("C:\\TEST\\MAYAPP.EXE")


0
 
vanilleCommented:
You can also use the CreateProcess function, then wait a "infinite" time with the waitforsingleobject...

Or better, do the same as before and create a timer (for the maximum time you want to wait in case of the process never end...) then wait with the waitformultipleobjects...

But I agree, it's a little more complicated that the spawn() function...

Good luck...
0
 
nietodCommented:
warmcat, that is still wrong.  the application name is "myapp" not "mayapp"!  :-)
0
 
trestanCommented:
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.
0
 
nietodCommented:
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.
0
 
trestanCommented:
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.
0
 
YinteoAuthor Commented:
Thanks!
0
 
nietodCommented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now