This is the mail archive of the
mailing list for the Cygwin project.
RE: Bash fails to run .bat file with spaces in pathname and argument
- From: "Buchbinder, Barry \(NIH/NIAID\) [E]" <BBuchbinder at niaid dot nih dot gov>
- To: <cygwin at cygwin dot com>
- Date: Fri, 13 Oct 2006 06:52:52 -0400
- Subject: RE: Bash fails to run .bat file with spaces in pathname and argument
* Johnathon Jamison (Wed, 11 Oct 2006 14:11:12 -0700)
> I am having some funny behavior. If I have a .bat file that is in a
> directory whose pathname contains a space, and an argument is given
> to the .bat file that has a space in it, then the .bat file fails to
> Instead, I get "'xxx' is not recognized as an internal or external
> command, operable program or batch file." where xxx is the portion of
> the complete path to the .bat file before the first space.
> I am not sure why this is occurring. Any help would be appreciated.
> I have more specific information and a sample run below. If I have
> left anything out, just ask. In particular, I am not sure which
> version numbers would be needed, or where to find (many of) them.
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
used to process quote (") characters:
1. If all of the following conditions are met, then quote
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,
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 "Documents and Settings"
To find out the short names,
Or one can guess (first 6 characters + "~" + "1", or a higher digit if
the 6 characters + "~1" is already used, + "." + first 3 characters of
Try changing the batch file from
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
exit' | u2d | cmd /k
c:\>"c:\Documents and Settings\BBuchbinder\test.bat" "hello world"
c:\>echo "hello world"
You can leave off the "/k", but you then get extraneous text from
cmd.exe as it loads.
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html