Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is it that Cygwin can run .bat scripts?

When I execute a .bat script from bash in Cygwin, by what mechanism is it running? I understand that if I run a .EXE it will launch, regardless of whether the .EXE is from Cygwin or from a more traditional environment. I understand that when I execute an executable script with #! at the beginning that Cygwin supplies the magic for it to run.

But why does a .bat script work? Is there some component inside of Cygwin that is aware of what a Windows .bat script is and what to do with it? Or is it that it is somehow impossible under Windows to execute a call to launch a .EXE file that won't automatically also work for a .bat script instead?

like image 297
skiphoppy Avatar asked Apr 24 '09 20:04

skiphoppy


People also ask

What program runs .BAT files?

When a batch file is run, the shell program (usually COMMAND.COM or cmd.exe) reads the file and executes its commands, normally line-by-line. Unix-like operating systems, such as Linux, have a similar, but more flexible, type of file called a shell script. The filename extension .bat is used in DOS and Windows.

What is the difference between .exe and .BAT files?

A . BAT (short for "batch") file is a plain text file that contains a series of Windows commands. An . EXE (short for "executable") file is a binary file that contains much more complex executable binary code.


1 Answers

Running

./test.bat params

from bash seems to be equivalent to

cmd /c test.bat params
like image 155
Tunzi Avatar answered Oct 31 '22 06:10

Tunzi