I have a batch file (ppp.bat) with only two lines in it:
start .
exit /b 23
start .
exit /b 23
To copy to clipboard, switch view to plain text mode
The C++ code to call QProcess::start is this:
myProcess->start(program);
myProcess->waitForStarted();
myProcess->waitForFinished(1000);
QString strExitCode
( "ExitCode is %1 ExitStatus is %2");
strExitCode = strExitCode.arg( myProcess->exitCode()).arg( (int) myProcess->exitStatus());
ui->textEdit->append( strExitCode);
QString program = "c:\\ppp.bat";
QProcess *myProcess = new QProcess(this);
myProcess->start(program);
myProcess->waitForStarted();
myProcess->waitForFinished(1000);
QString strExitCode( "ExitCode is %1 ExitStatus is %2");
strExitCode = strExitCode.arg( myProcess->exitCode()).arg( (int) myProcess->exitStatus());
ui->textEdit->append( strExitCode);
To copy to clipboard, switch view to plain text mode
It always prints 0 for exitCode.
What is needed to have this function return 23?
Oh the OS is Windows XP SP 3 and the Qt is 4.8.1 compiled with VS2010.
Thanks.
Bookmarks