Running .bat files from PATH in Cygwin

0

1

Running .bat files in Cygwin (bash or zsh) works when calling directly.

However, if I'm located at a different folder and I call the .bat file by relying on PATH variable, it will say command not found.

If I have a .bat file in environment PATH, how can I make Cygwin to execute it from any directory? This works for .exe files but apparently not for .bat files.

Kai Sellgren

Posted 2014-08-30T10:01:11.037

Reputation: 109

Answers

1

It sounds like you need to be more specific. It does work for BAT files and EXE files. What may be happening is that you are coincidentally using a name that is already taken by something earlier in your path.

If you have PATH=C:\1;C:\2;C:\3

And you make a C:\3\foo.BAT

But there is already a C:\1\foo.EXE

Then when you type "foo", it will hit c:\1\foo.exe before finding c:\3\foo.bat.

This has plagued me from time to time.

I find the "which" command helpful in these situations.

ClioCJS

Posted 2014-08-30T10:01:11.037

Reputation: 118

PATH delimiter is ; not , – Hannu – 2015-08-19T18:53:25.490

Good catch. I was thinking verbally but writing as if it was code. Bad habit! :) – ClioCJS – 2015-08-20T18:38:41.877