I am trying to run an executable from a c++ program. I have looked and found 2 options:
system("C:\filepath\file.exe");
and
ShellExecute(GetDesktopWindow(), "open", "C:\filepath\file.exe", NULL, NULL, SW_SHOWNORMAL);
Everything is beautiful, except it doesn't work.
For the first option, I had to include, apart from windows.h, also cstdlib, otherwise my code didn't build.
When I run the program, I get the error:
"file.exe" is not recognized as an internal or external command
I have set the Common Language Runtime Support (/clr) option for my project (and I also had to set the option Multi-threaded Debug DLL (/MDd) for the Runtime Library, otherwise again, it wouldn't build).
The second option will not build even with both libraries included. I get error:
error C3861: 'ShellExecute': identifier not found
I am using VS2010 on Windows7 - and would like this to work on multiplatform...
Am I asking too much ?
Thank you.
ShellExecute. Yoursystemcommand is correct; it sounds like you gave it an incorrect path.system():system("C:\\filepath\\file.exe");. Chances are your first code snippet will work as expected then.