QProcess issue in executing a exe with command line arguments
Hi,
I have a issue in setting the QProcess to run executable with the arguments. The Qt code for the same is as below,
Code:
// some path where i require the output
processSQLDB->setWorkingDirectory(sToolAccessfilepath);
QString sExeName
= "\"D:/app 1/app.exe\"";
sArgs << "DBFile.db";
sArgs << "<";
sArgs << sDataFileName;
processSQLDB->start( sExeName , sArgs);
if (!processSQLDB->waitForStarted())
return false;
// to display stdout, stderr,this gives an empty string
qDebug() << processSQLDB->readAll();
The output of this snippet is the creation of the file "DBFile.db". But it is not happening. Am i doing any mistake?
But if i goto cmd prompt and execute the same thing like.,
c:/> "D:/app 1/app.exe" DBFile.db < sDataFileName. This works perfectly.
Re: QProcess issue in executing a exe with command line arguments
you need to use escape character for the slashes.
Re: QProcess issue in executing a exe with command line arguments
Even after putting escape character it is not working. And the other thing what i observed is
1) The exe(exe without args)invokes only if i use startDetached(...) method but not start(...).
2) Even if the exe do not contains path and i try to execute the QProcess() plainly having all the required files in the current directory then also am not able to get the output. But if use something like this ,
Code:
QString str
= "app.exe" + " DBFile.db" + " < " + sDataFileName;
system(str.toAscii());
This works!!,But the problem is, this flashes the cmd window, which is not appreciated. Any inputs would be helpful. Thanks.
Re: QProcess issue in executing a exe with command line arguments
Quote:
even after putting escape character it is not working. And the other thing what i observed is
Please post the code
Re: QProcess issue in executing a exe with command line arguments
did you use waitForFinished() before taking out the std output
Re: QProcess issue in executing a exe with command line arguments
Quote:
Originally Posted by
MrDeath
did you use waitForFinished() before taking out the std output
yes. I tried that too. But there won't anything directed stdout, the confirmation is creation of the DBfile.db. And also there is no any stderror data too. Let me know if anything need to do.
Quote:
Originally Posted by
high_flyer
Please post the code
I have used the same code posted above with small changes as suggested below,
First way:
Code:
QString sExeName
= "\"D:\\app 1\\app.exe\"";
Second way:
Code:
QString sExeName
= "\"D:/app 1/app.exe\"";
And also as said in the above post, even i dump all the files in the current directory then also there is no output, means creation of file but whick works with the 'Sytem(...) command.
Re: QProcess issue in executing a exe with command line arguments
Guys, Please let me know if you have any inputs?
Re: QProcess issue in executing a exe with command line arguments
try this:
Code:
QString sExeName
= "D:\\app 1\\app.exe";