Problem executing a .bat script in a directory with spaces using bash

Sean Daley spdaley@gmail.com
Thu Sep 2 15:38:00 GMT 2004


I'm currently using cygwin 1.5.10 and I'm having a problem trying to
run a .bat file in
a directory with spaces.  Here's an example of what I'm doing.

1) mkdir C:\Space Dir
2) Create a file called test.bat in C:\Space Dir
3) Just add a single line with "echo %1" in test.bat
4) Start cygwin
$ cd C:/Space\ Dir
$ ./test.bat hello

c:\Space Dir>echo hello
hello

$ ./test.bat "hello world"
'c:\Space' is not recognized as an internal or external command,
operable program or batch file.

$

If I try to run test.bat with an argument with spaces it fails with
the error above.
If I move test.bat to a directory without spaces, it works correctly.

I know that cmd has some weird behavior when you execute a quoted cmd.
Just using cmd in certain ways (outside of cygwin) will reproduce the
issue mentioned
above.

Do the following:
C:\>cmd /c "C:\Space Dir\test.bat" hello

C:\>echo hello
hello

C:\>cmd /c "C:\Space Dir\test.bat" "hello world"
'C:\Space' is not recognized as an internal or external command,
operable program or batch file.

One way to actually get the second command to work is to quote the
entire command
like this:

C:\>cmd /c ""C:\Space Dir\test.bat" "hello world""
C:\>echo "hello world"
"hello world"

Unfortunately we have some batch scripts which live in directories
with spaces that I'd
really like to run.

Thanks.

Sean
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygcheck.out
Type: application/octet-stream
Size: 18045 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20040902/d3665e07/attachment.obj>
-------------- next part --------------
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


More information about the Cygwin mailing list