Opening an .exe file using C++

This might be a little advanced but I want to run an .exe file using Visual C++. I have tried to look for ways to do this but nothing I tried would run the program. With the last code I tried that work, it said the file path "is not recognized as an internal or external command, operable program or batch file. The system cannot find the path specified."
Here is the code I tried to used:

#include <windows.h>
using namespace std;
int main()
{
system ("C:/Users/User/folder1/folder/File.exe");
return 0;
}

I am using Microsoft Visual Studio Express 2013 if that helps any. I am still new to C++ so excuse me if I did something stupid.
Last edited on
Use ShellExecute: https://msdn.microsoft.com/en-us/library/windows/desktop/bb762153%28v=vs.85%29.aspx

Please click the "Edit Topic" button at the top of this page, and move this topic to the Windows Programming forum.
You shouldn't use system, but if you put "START " before the file path it should work.
I'm also new here and I'm looking forward to learn from you guys.
How to access mozzila from c++ code for example it will click button on any webpage ?


Last edited on
You can't. You probably can only if you have the Mozilla embedded browser running inside your application, but this is overkill. Besides, browsers are specifically designed to guard against this kind of thing because of the security implications.
@ matteodoors: Don't hijack other peoples threads. Secondly, you can use what are called 'XPCOM' and 'XPIDL' to do this:

- https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM
- https://developer.mozilla.org/en-US/docs/Mozilla/XPIDL

These are the interface definition language and object model that you use to write extensions for Firefox.
Topic archived. No new replies allowed.