cmd = "start /b "+fileName;
system(cmd);
// result string: "start /b filename"
// does not work when file name has spaces
cmd = "start /b \\""+fileName+"\\"";
system(cmd);
// result string: "start /b \\"filename\\""
// does not work
cmd = "start /b """+fileName+"""";
system(cmd);
// result string: "start /b filename"
// does not work
char quote = 34;
cmd = "start /b "+quote+fileName+quote;
system(cmd);
// result string: "start /b \\"filename\\""
// does not work
Why does your second solution not work ? What happens ?
For me this seems to be the correct approach.
Note also that system() internally prepends "cmd /c"
Why does your second solution not work ? What happens ?
For me this seems to be the correct approach.
Note also that system() internally prepends "cmd /c"
It does not work because the result string is "start /b \\"filename\\"", with the backslash before the quotes.
Your second solution should not have the backslashes in the result.
Are you maybe testing the result with a Debug command and the log viewer?
In the log viewer there will be slashes added but these are not really in the string. It's just for the output (got me confused some time ago, too).
Your second solution should not have the backslashes in the result.
Are you maybe testing the result with a Debug command and the log viewer?
In the log viewer there will be slashes added but these are not really in the string. It's just for the output (got me confused some time ago, too).
You are right, I just noticed that as well. I converted to a blob, and only the quote character appears in the string.
I just managed to solve my problem. The problem was with the start function, which expects the following syntax:
START "title" [/D path] [options] "command" [parameters]
it opens the file correctly. It was missing the first parameter (title). Strangely when I didn't use the quotes it worked correctly, as long as there were no spaces in the path.