0

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.

wookie1
  • 511
  • 6
  • 18

1 Answers1

3

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).

NPE
  • 486,780
  • 108
  • 951
  • 1,012
  • ``, because there is C++ tag – Abyx Dec 14 '11 at 16:12
  • Thanks, do you know a way to make this work with successive commands i.e. i tried system(cd /home/file); system(cat test.txt); where test.txt is located in file. That didn't work but system(cat /home/file/test.txt); did. – wookie1 Dec 14 '11 at 16:51
  • Solved as described here: http://stackoverflow.com/questions/245600/using-a-single-system-call-to-execute-multiple-commands-in-c – wookie1 Dec 14 '11 at 17:43