[Qt-interest] QProcess problem when argument has space in windows

David Ching dc at dcsoft.com
Sat Mar 14 16:13:55 CET 2009


> Hi all
> 
> I am using Qt 4.5. I am trying start a msi install by calling
> msiexec.exe using QProcess. I am passing the path of the msi which has
> spaces in the path. I do put them between quotes. It just does not
> work... here is the code below
> 
> int SetupWrapper::startProcess(QString args)
> {
> QString program = "msiexec.exe " + args;
> QProcess *myProcess = new QProcess(this);
> myProcess->start(program);
> myProcess->waitForFinished(-1);
> int errorcode=myProcess->exitCode();
> myProcess->close();
> return errorcode;
> }
> 
> void hari(...)
> {
> int res = startProcess("/i \"C:/New Folder/Dummy.msi\"
> MSIS=\"|C:/Documents and
> Settings/hari/Desktop/setup/store.msi|C:/Documents and
> Settings/hari/Desktop/setup/Tool.msi\"");
> }
> 
> I even tried replacing \" with \"\"\" when argument has spaces after
> looking at this site
> http://doc.trolltech.com/4.1/qprocess.html#start-2
> like below....
> void hari(...)
> {
> int res = startProcess("/i \"\"\"C:/New Folder/Dummy.msi\"\"\"
> MSIS=\"\"\"|C:/Documents and
> Settings/hari/Desktop/setup/store.msi|C:/Documents and
> Settings/hari/Desktop/setup/Tool.msi\"\"\"");
> }
> 
> Nothing seems to work.... the msi does not get executes.. msiexec gives
> out error arguments wrong...
> 
> is this a bug or am i doing something wrong???
> 
> thanx
> Hari
> 
> Note: i tried this is C# and it works perfectly....
> 
> 


Easiest thing is to debug and trace into QProcess::start().  What parameters
is it passing to launch the app?  

You are also specifying '|' and I'm not sure this is correct? 

Another thing is to launch a file with another extension like .foo (instead
of .msi) which launches a test app that you wrote which has registered as
the app for .foo.  Your test app could simply show a messagebox of its
parameters, so you see how Qt has launched it.

-- David




More information about the Qt-interest-old mailing list