Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Running a separate Executable from the application

Posted on 2002-03-04
Medium Priority
Last Modified: 2010-04-01
I am needing to run one executable from within another application.  For instance, assuming that I have a basic "Hello World" application, how would I open it from a separate application and print "Hello World" to the screen.  Basically, I am needing to know how to run command line commands within my code.  

// very simple example code
void main()
   // run "Hello World" application here
   // from the command line, it would look like
   // c:/hello.exe

   // do more processing...
Question by:guile1
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 86

Accepted Solution

jkr earned 800 total points
ID: 6840554
The easiest way would be using "system()".

/* SYSTEM.C: This program uses
 * system to TYPE its source file.

#include <process.h>

void main( void )
   system( "type system.c" );


/* SYSTEM.C: This program uses
 * system to TYPE its source file.
#include <process.h>
void main( void )
   system( "type system.c" );

In your case, just change it to read

   system( "hello.exe" );

You might have to provide a path, though...

Expert Comment

ID: 6840932
i feel best to use is

 pass the paramater which ever file u want to execute
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 30

Expert Comment

ID: 6841154
You mean ShellExecute...???

Expert Comment

ID: 6841190
system() call is the easiest to call an application. If u need more control over the way the new application is started you can use ShellExcuteEx() method. You can set different options like how the applcation should be started ( minimized, maximized etc. ) by filling the SHELLEXECUTEINFO structure and passing it to the ShellExecuteEx method.

Cheers !!!

Author Comment

ID: 6841463
Thanks.  I will give it a try.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

722 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