I have a weird problem in MATLAB. I'm trying to run an exe, say test.exe. This is in a folder/directory which has spaces in the name. C:\users\abc\test folder\test.exe. I'm saving the path to a variable so I don't have to type it out everytime, and the code is cleaner.
I see a very weird problem. The space in the path causes a problem only if I have to save the command output. Interestingly, the problem doesn't occur if I run the exe without any arguments. In this case the cmdout is properly logged (like most exes, this exe gives usage instructions when you run it without any arguments)
exe_path = 'C:\users\abc\test folder\test.exe';
>> NO PROBLEM
[status, cmdout] = system([exe_path,' arg1'])
>> ''C:\users\abc\test' is not recognized as an internal or external command, operable program or batch file'
[status, cmdout] = system(exe_path)
>> NO PROBLEM
I've tried double quotes, single quotes, single and double quotes (based on some other answers), but I can't fix this isssue. The simple solution would be to move the exe or rename the folder, but this is a common install path for anyone in my ecosystem installing the tool and there are a lot of dependent dlls that the exe uses. Moving all this to a new folder will place a lot of dependencies when I will have to distribute the utility I am trying to create in MATLAB.
Let me know if there is a fix for the above problem.