Regarding the additional question of why the extra quotes are needed: this is described in the help returned by cmd /?
, specifically
If /C or /K is specified, then the remainder of the command line after
the switch is processed as a command line, where the following logic is
used to process quote (") characters:
1. [Special case, not relevant here]
2. Otherwise, old behavior is to see if the first character is
a quote character and if so, strip the leading character and
remove the last quote character on the command line, preserving
any text after the last quote character.
So, if the first (non-whitespace) character of the command is a quote, you need an extra pair of quotes around the entire command.
Additional note: combining MC ND's answer with mine, the first command line in the question is being interpreted like this: we start with
"cmd /C" "C:\\Program Files\ABC\xyz.exe" -register="abc"
which becomes
%ComSpec% /C" "C:\\Program Files\ABC\xyz.exe" -register="abc"
due to the rule that replaces cmd
-> %ComSpec%
combined with the bug/feature that discards the extra quote mark; this then becomes
"C:\\Program Files\ABC\xyz.exe" -register="abc
because of the rule that removes the first and last quote marks when processing /C
.
The Win32 file system rules discard the extra backslash, so the executable launched is
C:\Program Files\ABC\xyz.exe
and the executable is presumably ignoring the missing close-quote in its argument.