PDA

View Full Version : problem about QProcess:: startDetached



yuzhouzhiwai
20th April 2015, 04:34
Hi,
I want to start a bat shell on Windows XP, and I use QProcess::startDetached() function to start the bat shell.

bool QProcess::startDetached ( const QString & program, const QStringList & arguments, const QString & workingDirectory, qint64 * pid = 0 )

If the first parameter is setted to a absolutely path, everything is ok. But if the first paramter is setted to a relative path, the shell(console) just flash across and the process started failed.

Then, I try to add "PAUSE" to the bat shell, but it dosen't pause.
Then, I think that Maybe the startDetached function dosen't get the correct path. But if I remove the bat shell file, there is nothing happen, so I think QProcess::startDetached function is sure to get the bat shell file, it just cannot start the bat shell successfully.

Anyone know what's the problem?
Thankyou very much

ChrisW67
20th April 2015, 09:48
Using a relative path for the command to run will look for the specified program in the current working directory of the launching process first, which is probably not where you think it is, then the system PATH. If the program is not found in either place then it will fail.

yeye_olive
20th April 2015, 10:05
You forgot in your post to tell us what value was returned by QProcess::startDetached().