Running another .exe file in my program

Sep 15, 2008 at 7:00am
Hello people

I have a small question regarding running a .exe file from my program is possible ?
For ex : My main program is main.exe in C:\Test folder
Like after taking the user's input for ex: If user presses (1) - run 1.exe which is located in the same working directory (C:\Test). Is it possible to do that ?

NOTE: Both main.exe and 1.exe are console progams
Last edited on Sep 15, 2008 at 7:03am
Sep 15, 2008 at 7:18am
Well, the simplest and ugliest way to do this would be to use system("1.exe").
The proper way to do this is by calling OS function CreateProcess().

http://msdn.microsoft.com/en-us/library/ms682425.aspx
Sep 15, 2008 at 10:49am
Err why do you say that system() is the ugliest way and CreateProcess() the proper ? Explain ? And also which header file should i inlude so as to access both of those functions ?
Sep 15, 2008 at 2:18pm
cstslib for one and windows.h for the other.

http://www.cplusplus.com/forum/beginner/1988/
Topic archived. No new replies allowed.