[vbox-dev] Regarding possible solution to #13157 - Windows Command line argument handling error

Magnus Madsen madsen.magnus at gmail.com
Tue May 5 06:39:16 GMT 2015


On Mon, May 4, 2015 at 10:53 PM, Knut St. Osmundsen
<knut.osmundsen at oracle.com> wrote:
>
> Hi Magnus,
>
> seems notepad.exe and few other windows apps are doing it for
> themselves...  So, I've added an option to disable the quoting and
> escaping.
>
> New test build:
> https://www.virtualbox.org/download/testcase/VirtualBox-4.3.27-100026-Win.exe
>
> Try: VBoxManage guestcontrol <vm> exec [creds] --unquoted-args -- \
>          c:\windows\system32\notepad.exe test=\"test\"
>
> Notepad should now see test="test" and tell you off for giving in an
> incorrect name.
>
> Note! The --unquoted-args option only disables the final
> RTGetOptArgvToString(,,MS_CRT) right before CreateProcessW is called
> on the guest side.  On the VBoxManage command line, the shell/CRT will
> interpret your command line first and turn it into argv, which is send
> to the guest, thus the escaped double quotes (\").
>
> Kind Regards,
>  bird.

Hi Knut,
The new option does work as advertised; it sends the arguments
directly to the new process without stripping characters or enclosing
it in quotes. I'm not positive that adding the new argument is the
best solution though. For information's sake, could you let me know
what processes I can test that act differently than notepad.exe with
regards to the command-line arguments?

My suggestion for the conditional quoting would be:
* If the argument contains a space, then enclose it in double quotes.
* Do the above unless the argument only contains a space within two
double quotes.

That is to say:
argument argument -> "argument argument"
argument="data + data" -> argument="data + data"

(This all makes the most sense when using the VirtualBox interface, it
is a little more clunky when using VBoxManage.)

Running
VBoxManage guestcontrol <vm> exec [creds] --unquoted-args notepad.exe
test=\"test\" "argument 2"
starts the process with the arguments -- test="test" argument 2 --
which seems counter intuitive to me. To get the correct result,
test=\"test\" \"argument 2\" is necessary.

The fix would be sufficient for my usage, but I think that if the
quoting was changed as described above we would not actually need the
ProcessCreateFlag_UnquotedArguments.

Thank you so much for the help!

Kind regards,
Magnus




More information about the vbox-dev mailing list