Run and close another program

Hello everyone
I wish to write a program wich run and close two difrent program. And when it run one of these two program second one truning of. Actually this program should controlling rwo another programs.

And BTW I can start another program whic iss install on windows but I can´t close this program and after that automatically run second program.

Thank you everyvone who answer on this post.
Last edited on
is there any way to use somthing like this for close program:
thi is run program:
system("start C:\\Appfolder\\name.exe")
but for close porgram I don´t know how to do that
No, if you use system() you have to wait until the program finishes. There are though ways to close the program, again depending on your OS. If you're on windows you can use the SendMessage function to send a WM_CLOSE message to the window of the process you want to terminate.

http://msdn.microsoft.com/en-us/library/ms644950%28VS.85%29.aspx
http://msdn.microsoft.com/en-us/library/ms632617%28VS.85%29.aspx

EDIT: There's TerminateProcess too, but this doesn't give the program time to do any necessary cleanup before it stops.

http://msdn.microsoft.com/en-us/library/ms686714%28VS.85%29.aspx
Last edited on
I will try functions which are on links and I hope it helps
Last edited on
Problem staying
Now I will replay what I wish to do in my program I wish run two diferent progrqams which are in my OS (Windpws). And when writen program running automaticaly switching from program to program

Example:
Run program 1 and if in this time runing program 2 than close it (program 2)

Please do not give me complete source code of this program.
Give me just function which run one program, function which close one program and function which will be controling the user (when he/she close program).

I was trying Create Process () and similar but I don´t understand code and compiler (GCC) always displaying error.
info I using wxDev c++ - IDE
Can anyone write toutrrial in this mode which are other toutrials in this site (A lot of examples) I will be very happy if anyone do this.
Please help anyone who can.
Last edited on
Topic archived. No new replies allowed.