Hi all,
I want to use a user command to post-process the axf file. I enclose the command in quotes to preserve spaces in the path. However, if I also use quotes to enclose parameters in quotes, then the external command does not get called. If I don't enclose the parameters in quotes, the external command is called but the parameter is not parsed correctly.
As an example, a batch file called test_cmd.bat:
echo Parameter 1 = %1 echo Parameter 2 = %2
If I call this using
"C:\nXDS\nXDS Interface Processor\Application\Release\test_cmd.bat" #L
I get
User command #2: "C:\nXDS\nXDS Interface Processor\Application\Release\test_cmd.bat" C:/nXDS/nXDS Interface Processor/Application/Release/Obj/nXDS.axf C:\nXDS\nXDS Interface Processor\Application>echo Parameter 1 = C:/nXDS/nXDS Parameter 1 = C:/nXDS/nXDS C:\nXDS\nXDS Interface Processor\Application>echo Parameter 2 = Interface Parameter 2 = Interface ".\Release\Obj\nXDS.axf" - 0 Error(s), 0 Warning(s).
The batch file is called but the parameter is split by the spaces.
If I call using
"C:\nXDS\nXDS Interface Processor\Application\Release\test_cmd.bat" "#L"
User command #2: "C:\nXDS\nXDS Interface Processor\Application\Release\test_cmd.bat" "C:/nXDS/nXDS Interface Processor/Application/Release/Obj/nXDS.axf" --- Error: User Command terminated, Exit-Code = 1 ".\Release\Obj\nXDS.axf" - 1 Error(s), 0 Warning(s).
The batch file does not appear to have been called when both the command and parameter are in quotes.
Apart from the obvious workaround of not using a path containing spaces, is there any solution for this problem?
Regards
But another thing about spaces is that you can use backslash+space ("\ ") to allow a path to contain a space without needing quotes around the path.
No, you can't. Not in command lines to be passed through any Microsoft command shell, anyway. No windows program has the slightest chance to know whether a command line of
PROGRAM.exe A\ B\C.txt
is supposed to mean that there's one file argument called "C.txt" in directory "A B", or two argument, one of which is "A\", and the other a file called "C.txt" in directory "B".
The only way to quote a blank in a command line (as opposed to the argv[] array passed to a Windows process creation API call) is by enclosing it in quotes.