How do you open a exe file programmaticaly?
My program is visual c++ mfc.
Printable View
How do you open a exe file programmaticaly?
My program is visual c++ mfc.
What do you mean by "opening" it?
Running it? If so, you can just include <cstdlib> and use the system() function to run it.
that doesnt work and yes how to run a exe.
There are some other functions like _spawnl, _spawnp... and _execv, _execve... Look in the MSDN.
Why system() doesn't work? Try to execute it in a separate thread(for example look _beginthread or (I'm not sure for MFC) afxBeginThread()) and may be will work.
system works fine, tell us what you did.Quote:
Originally posted by immortal20
that doesnt work and yes how to run a exe.
Try ShellExecute() or CreateProcess() ..
well i included the #include <cstdlib>
then i used this to run a exec
system("C:\\Documents and Settings\\BBY Tech\\Desktop\\Fixs DAP 1.0\\spybotsd12.exe");
and then a msdos window opens and closes right away.
Well what the program has to do? Because if it is something small it does it and terminate. If you have to enter some data it should stop and wait you to enter something. Otherwise this : system("C:\\Documents and Settings\\BBY Tech\\Desktop\\Fixs DAP 1.0\\spybotsd12.exe"); is correct.
well what i want it to do is when i click on this button it brings the spybot installation program.
ok i got it working, now is there a way to get rid of that msdos screen. it says C:\windows\system32\cmd.exe in the title bar.
Yes, use CreateProcess (assuming that the exe is not a console based exe of course).
wow there is alot of paremeters in there, can you give me and example in code on how to use all of those paremeters.
Okay, the last parameters are output structures. Create them and pass them in. Do NOT make them NULL.
The first parameter should be null (for the time being).
The second parameter is your command line.
Third and fourth parameters should be null (for the time being). Fifth parameter - FALSE.
Sixth parameter - NORMAL_PRIORITY_CLASS
Seventh paramter - NULL (for the time being)
Eighth parameter - NULL (for the time being)
Lookup MSDN if you would like to know what each parameter is/does.
CreateProcess(NULL,"C:\\spybotsd12.exe",NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,FALSE,NULL,NULL,NULL);
this is giving me an error when i run the program.
it dosent take 8 parematers
Read the first line of my previous reply.
Then tell me what error.
Yes it takes 10 parmeters.
i got it thanks alot man
Just remember that you now have two open handles.
The answer could have been easily found in the following FAQ... :cool: