1
votes

I am using QProcess on Windows and I have a problem running an exe file that is located in Program Files. Trying to run the same with the CreateProcess() function works ok. Space in the path is not the problem. I think it is related to user access rights or something similar. I can use the CreateProcess() but I would like to know if there is any way how to get QProcess working as I need.

My code looks like this:

QProcess* myProcess = new QProcess(this);
myProcess->setProcessEnvironment(myEnvVars);
myProcess->start("myExePath");

Edit: My platform is Visual Studio 2015 and Qt 4.71

1
I think It relates to access right. Try to call GetLastError function after creating the process, the returned value should be 5, or launch your application with administrator rights, to be sure that problem connected with access rights. - arturx64
Try to call waitForStarted() method after start. - arturx64
Why are you sure about spaces? The CreateProcess and the QProcess::start method you are using treats the string you provide differently - may be the same issue as in this question - Mikhail Churbanov
@MikhailChurbanov Yes I know that question but it is not this case. I did several tests to be sure. - ni1ight
@ni1ight, that's strange then. I would suggest using the setCreateProcessArgumentsModifier with the same configuration you used for the CreateProcess that is working. Cause the start method actually calls it inside. There might be an issue with the Pipes set instead standard IO in QProcess, or usage of handles inheritance by default... - Mikhail Churbanov

1 Answers

0
votes

I had the same issue and I have used startDetached Method and it worked.

QProcess* myProcess = new QProcess(this);
myProcess->setProcessEnvironment(myEnvVars);
myProcess->startDetached("myExePath");