Solved

Function to execute applications

Posted on 1998-07-24
13
207 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
0
Comment
Question by:Yinteo
13 Comments
 
LVL 84

Expert Comment

by:ozo
Comment Utility
#include <stdlib.h>
int system (const char *string);
0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
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
 
LVL 22

Expert Comment

by:nietod
Comment Utility
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
 
LVL 8

Expert Comment

by:trestan
Comment Utility
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
 
LVL 22

Expert Comment

by:nietod
Comment Utility
And ShellExecute() as well.
0
 
LVL 2

Expert Comment

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


0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Accepted Solution

by:
vanille earned 200 total points
Comment Utility
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
 
LVL 22

Expert Comment

by:nietod
Comment Utility
warmcat, that is still wrong.  the application name is "myapp" not "mayapp"!  :-)
0
 
LVL 8

Expert Comment

by:trestan
Comment Utility
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
 
LVL 22

Expert Comment

by:nietod
Comment Utility
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
 
LVL 8

Expert Comment

by:trestan
Comment Utility
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
 

Author Comment

by:Yinteo
Comment Utility
Thanks!
0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
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

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now