The problem is, at least in part, with cmd. cmd /? says:
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. If all of the following conditions are met, then quote
characters
on the command line are preserved:
- no /S switch
- exactly two quote characters
- no special characters between the two quote characters,
where special is one of: &<>()@^|
- there are one or more whitespace characters between the
the two quote characters
- the string between the two quote characters is the name
of an executable file.
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.
Try using short names to get rid of the first set of quotes. Short
names still work, at least on XP. Compare
c:\>dir docume~1
and
c:\>dir "Documents and Settings"
To find out the short names,
c:\>dir /x
Or one can guess (first 6 characters + "~" + "1", or a higher digit if
the 6 characters + "~1" is already used, + "." + first 3 characters of
the extension).
Try changing the batch file from
echo %1
to
echo %1 %2 %3 %4 %5 %6 %7 %8 %9
That should work by getting rid of the second set of quotes, at least if
the number of arguments is less than 10.
This, also, works
/c> echo '"c:\Documents and Settings\BBuchbinder\test.bat" "hello
world"
exit' | u2d | cmd /k
c:\>"c:\Documents and Settings\BBuchbinder\test.bat" "hello world"
c:\>echo "hello world"
"hello world"
c:\>exit
You can leave off the "/k", but you then get extraneous text from
cmd.exe as it loads.