wookie1
wookie1

Reputation: 511

Running .exe from c++

My problem is that I need to run a .exe program from my c++ program. When running the .exe in shell I go to the .exe location, run the .exe, in the shell it then requests the input file which I then provide. The program then runs. From my research I believe I need to use shell32 but I'm having some problems. I'm currently programing on a linux machine (opensuse). Will shell32 still work in this scenario, if so does anyone know where the library should be located as I can't find it on my PC to link to. The other issue I potentially see is the way the program runs, as I said in shell you run the program then provide the arguments whereas all the examples I can find for shellexecute give arguments in the same call. If there is a better solution available I'm open to it. Ideally this should work on windows and linux machines but if I had to choose I'd have to go for windows. Thanks in advance.

Upvotes: 0

Views: 1695

Answers (1)

NPE
NPE

Reputation: 500853

shell32 is Windows-specific.

One fairly portable way to run external executables is by using the system() call:

SYNOPSIS
       #include <stdlib.h>

       int system(const char *command);

Now, the executable that you wish to run has to be built for the operating system on which you're trying to run it. If you want to run a Windows .exe file on Linux, you're entering the realm of emulation (e.g. Wine) or virtualization (e.g. VirtualBox).

Upvotes: 3

Related Questions