0

I have inside the output folder a folder called foo with an executable a.exe that I would like to call. Unfortunately it isn't opening and whatever is the directory I pass to setWorkingDirectory, I get an error output.

The code:

QProcess proc;
proc.setWorkingDirectory("foo"); //tried full path, warap in quotes etc..
proc.setProgram("a.exe");
proc.start();

Checking error:

qDebug() << "error = " << proc.error();

It outputs:

0 value which is QProcess::FailedToStart (see QProcess::ProcessError)

I want the application to start from its working directory and not the caller executable's working directory because of the dependencies files.

BaCaRoZzo
  • 7,502
  • 6
  • 51
  • 82
Jack
  • 16,276
  • 55
  • 159
  • 284
  • The most often reason for `QProcess::FailedToStart` is incorrect path given in `setProgram`. Did you try to specify full path to `a.exe`? I doubt that `QProcess` will search program in directory set as working. – dvvrd Dec 19 '15 at 16:54
  • Might be a path issue, try using absolute paths. – MrEricSir Dec 19 '15 at 17:13
  • 2
    QProcess requires an absolute path, the working directory is independent of the executable location. See also QProcess::errorString() – Frank Osterfeld Dec 19 '15 at 17:30
  • @FrankOsterfeld: Totally missed out this. I giving the filename only because I thought it would someway cd for that then run the executable. Post it as answer so that I can accept – Jack Dec 29 '15 at 21:36

0 Answers0