Since nothing in the batch file refers to the directory, it looks like cmd.exe/command.com received the full path when executed. Compare the following under cmd.exe (XP pro) and bash.
=================== c:\tmp> type t.bat echo x %0 x echo %1 %2 %3 %4 %5 %6 %7 %8 %9 c:\tmp> t.bat a b c d e f g h i j k l m c:\tmp> echo x t.bat x x t.bat x c:\tmp> echo a b c d e f g h i a b c d e f g h i =================== /c/tmp> cat t.bat echo x %0 x echo %1 %2 %3 %4 %5 %6 %7 %8 %9 /c/tmp> t.bat a b c d e f g h i j k l m n o p c:\tmp> echo x c:\tmp\t.bat x x c:\tmp\t.bat x c:\tmp> echo a b c d e f g h i a b c d e f g h i =================== So the problem with spaces is that they are not being passed quoted. I tried specifying the full path to the batch file and it worked for me. YMMV. =================== /c/tmp> /c/Program\ Files/t.bat a b c d e f g h i j k l c:\tmp> echo x "c:\Program Files\t.bat" x x "c:\Program Files\t.bat" x c:\tmp> echo a b c d e f g h i a b c d e f g h i =================== You might try specifying the full path with "short" names (8.3) to remove the spaces. The following is XP Pro with NTFS. =================== /c/tmp> /c/progra~1/t.bat a b c c:\tmp> echo x c:\progra~1\t.bat x x c:\progra~1\t.bat x c:\tmp> echo a b c a b c =================== If that does not work in your case, you might having bash run a batch file in a directory without spaces and have that batch file call the batch file in the directory with spaces. Although cmd.exe may not receive a properly quoted %0 when called from bash, one would expect cmd.exe to get everything OK when called from cmd.exe. You may have to play with quotes, especially if you try to run a generic batch file. Don't forget to try quoting your double quotes so that cmd.exe gets the double quotes that it expects. Also, you might try other shells (bash, ash, etc.) in case this is shell-specific and not cygwin-specific. You might also try explicitly specifying cmd.exe and command.com, in case they behave differently. - Barry At Thursday, September 02, 2004 10:55 AM, Sean Daley wrote: > 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 -- 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/