spawnProcess command-line arguments help

Vladimir Panteleev via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Aug 5 00:34:36 PDT 2014


On Sunday, 3 August 2014 at 23:48:09 UTC, Martin wrote:
> When I use the spawnProcess function in std.process, the 
> command line arguments that I provide to the function seem to 
> get "quoted". Is there a way to tell the spawnProcess function 
> that I want the command line arguments to be non-quoted?
>
> Example:
> spawnProcess(["SomePath\\Test.exe"], ["-silent"]);

I assume you mean:

spawnProcess(["SomePath\\Test.exe", "-silent"]);

> and the command line becomes: "SomePath\Test.exe" "-silent" 
> (with the quotes exaclt like shown).
>
> Unfortunately (for some strange reason), the spawned process 
> only responds to non-quoted arguments passed through the 
> command line. So the command line should be exactly: 
> "SomePath\Test.exe" -silent
>
> Is there any way to achieve this?

No, there currently is no way to achieve this using spawnProcess. 
You could have better luck using spawnShell instead.

I would consider such behavior a bug in the application you're 
trying to run, as it does not perform command-line parsing 
according to convention (CommandLineToArgvW).

It would be possible to enhance spawnProcess and family to only 
quote arguments which need to be quoted, which would fix this 
particular case, however of course that can't address every 
program which parses its command line in a non-standard way.


More information about the Digitalmars-d-learn mailing list