rumca.js Posted August 4, 2009 Report Share Posted August 4, 2009 HelloI'm trying to invoke console program with parameter containing spaces (as one parameter). To make long story short I will say that I need to call program by CMD and with full path to applicationso it lookes like this:cmd /c "C:\Program Files\argumentator.exe" argument with space (4 arguments are passed into the program, but it's not what I intended)cmd /c "C:\Program Files\argumentator.exe" "argument with space" (does not work)cmd /c "C:\Program Files\argumentator.exe" \"argument with space\" (does not work either) Quote Link to comment Share on other sites More sharing options...
ɹəuəllıʍ ʇɐb Posted August 5, 2009 Report Share Posted August 5, 2009 So to clarify: the space characters are part of the argument, not to separate multiple arguments?When you say (does not work), does that mean that the space characters still work as separators? Quote Link to comment Share on other sites More sharing options...
rumca.js Posted August 5, 2009 Author Report Share Posted August 5, 2009 yes. space characters are part of argument."does not work" mean that the first quotes are not preserved. I don't know how to translate error message into english though; it's says that 'C:\Program' is not a name of a program.I read that the quotes are preserved only if there is one set of quotes (so I don't know if it is solvable...)http://www.microsoft.com/resources/documen...d.mspx?mfr=true Quote Link to comment Share on other sites More sharing options...
ɹəuəllıʍ ʇɐb Posted August 5, 2009 Report Share Posted August 5, 2009 Hmm, I really don't know how to solve that, although I think it should be possible.Does it work correctly if there are no space characters in the argument? If so, could you replace the actual space character (0x20) with a non-breaking space character (0xA0) ? Quote Link to comment Share on other sites More sharing options...
rumca.js Posted August 5, 2009 Author Report Share Posted August 5, 2009 Hm. If I replace every space character in query with non breaking space (160 dec, in my program -96 integer value, A0 hex, looks like á in console) problem still exists, quotes are not preserved, and cmd says 'C:\Program' is not a name of a program. Argument is passed correctly only if there's only one set of quotes, but it's cut into pieces when space occurs. So probably it was a good thought to look for something that would be substitue of quotes, or would be an escape characters for them (as well thought about non-breaking space about which I didn't know). Quote Link to comment Share on other sites More sharing options...
ɹəuəllıʍ ʇɐb Posted August 6, 2009 Report Share Posted August 6, 2009 In that case, try the DOS-style program path and name, like C:\PROGRA~1\ARGUME~1.EXE - this style should not need apostrophes (although the Microsoft doc on your earlier link says that '~' needs it; I don't believe it's necessary). Quote Link to comment Share on other sites More sharing options...
rumca.js Posted August 6, 2009 Author Report Share Posted August 6, 2009 the answer:C:\>cmd /c ""C:\Program Files\argumentator.exe" "argument with space""whole query must be surrounded with quotes. Thank you for your time and help :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.