Argument to System() with space in the path
-
Hi, dear all, I have a license check exe file with only one argument. CString exe = getCurrentProjectPath(); //e.g, C:\Temp CString pwd = "12345" CString exeString = exe + " \"" + pwd + "\""; system(exeString); everything works fines with above codes. But if I put double quota between exe, I get "filename, .... syntext is incorrect". CString exeString = "\"" + exe + "\" \"" + pwd + "\""; But if I don't put exe data in a quota, if the path has space, it also cannot work. How should I solve this issue? Thanks!
-
Hi, dear all, I have a license check exe file with only one argument. CString exe = getCurrentProjectPath(); //e.g, C:\Temp CString pwd = "12345" CString exeString = exe + " \"" + pwd + "\""; system(exeString); everything works fines with above codes. But if I put double quota between exe, I get "filename, .... syntext is incorrect". CString exeString = "\"" + exe + "\" \"" + pwd + "\""; But if I don't put exe data in a quota, if the path has space, it also cannot work. How should I solve this issue? Thanks!
CString exeString = (CString)"\"" + exe + (CString)"\" \"" + pwd + (CString)"\"";
EDIT: Added space between quotes.
The difficult we do right away... ...the impossible takes slightly longer.
-
Hi, dear all, I have a license check exe file with only one argument. CString exe = getCurrentProjectPath(); //e.g, C:\Temp CString pwd = "12345" CString exeString = exe + " \"" + pwd + "\""; system(exeString); everything works fines with above codes. But if I put double quota between exe, I get "filename, .... syntext is incorrect". CString exeString = "\"" + exe + "\" \"" + pwd + "\""; But if I don't put exe data in a quota, if the path has space, it also cannot work. How should I solve this issue? Thanks!
-
CString exeString = (CString)"\"" + exe + (CString)"\" \"" + pwd + (CString)"\"";
EDIT: Added space between quotes.
The difficult we do right away... ...the impossible takes slightly longer.
Richard, thanks for your reply. I try using double quota around all the arguments, not work. If you have multiple arguments that all are in double quota, you need to use "call". The following line works fine. CString exeString = "call \"" + exe + "\" \"" + pwd + "\"".
-
Richard, thanks for your reply. I try using double quota around all the arguments, not work. If you have multiple arguments that all are in double quota, you need to use "call". The following line works fine. CString exeString = "call \"" + exe + "\" \"" + pwd + "\"".
-
Then you should change the subject on your question and put a SOLVED at the end or at the beginning. And it would be nice that you would put the answer/solution there too. ;)
[www.tamautomation.com] Robots, CNC and PLC machines for grinding and polishing.