The process method is not working if I pass the user home directory programmatically in windows XP and windows 32 bit systems
The below code works fine:
QProcess process;
process.execute("C:/DOCUME~1/pjo/myprok/tmp/APP.exe");
Not working Code:
Here I am getting the path of the APP.exe using QDir::homePath
process.execute("C:/Documents and Settings/pjo/myprok/tmp/APP.exe");
The errorString returns “UnKnown error”
I tried with start method also which never works:
B Not working Code:
process.start("C:/Documents and Settings/pjo/myprok/tmp/APP.exe");
Error: Path Not found
process.start("C:/DOCUME~1/pjo/myprok/tmp/APP.exe");
Error : Unknown error
Your issue is probably due quoting issues caused by the spaces in the path (C:\Documents and Settings…).
Note that there are two overloads for start():
You are using the first, which takes the executable path and all args in one string, and expects it to be quoted correctly. Without quoting, “c:\documents” is interpreted as the executable and “and” “Settings…” etc. as the arguments.
The second version takes the arguments separately, and will interpret the executable path correctly, without any quoting needed. Thus, the easiest way is to use
This ensure the second version to be used, and should save you from all quoting issues.
I suggest to always use that overload.
The same applies to execute(), which is, as already said, a static method, so the error codes of the QProcess object won’t be set.