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.
Note that I wrote in my question: I have set the Common Language Runtime Support (/clr) option. I did that because of a previous error suggested it.
As soon as I removed that option, I was able to run the executable. Perhaps unmanaged code must remain unmanaged…