What is the difference between the a.bat, a.com and a.exe extensions?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Originally, a
.COMfile was a literal blob of 8086 code (that is, 16-bit x86). It is meant to be loaded at a fixed address, and the loader would jump straight to the first byte of its address. It’s also limited in size.An
.EXEfile has more header information. So it has required structures for things like dynamic linking, where code from a DLL can be patched into the.EXE‘s memory space at load time.. It originally comes from DOS, but it’s today used in Windows.However DOS and Windows eventually went to a model where the file extension in a
.COMand.EXEdidn’t mean anything. The program loader first checks the first two bytes of the file. If it happens to be the stringMZ(legend has it this stands for the initials of an early Microsoft employee), it will treat it as anEXE, otherwise it will load it as if it were aCOMfile. SinceMZdoesn’t map to a sensible x86 instruction to start a program, they can get away with this. Net effect: In some versions of DOS/Windows, an.EXEcan be named with.COMand vice versa. For example, in many versions of DOS/Windows, the famousCOMMAND.COMwas actually anEXE.I am not sure how much the previous paragraph applies to NT based versions of Windows. I’d imagine by now they’ve abandoned the
.COMstuff altogether.Lastly, a
.BATfile is a list of commands to be executed as if you typed them at your command prompt. However these days most people name them as.CMD.