Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.com, .bat, .exe whats the difference??? 1

Status
Not open for further replies.

DickyDoo

Technical User
Apr 16, 2003
3
GB
Windows uses the file extension to determine if the file is executable and which type of executable it is but why does it need different types and what are the differeneces, if any in the way that it executes them?

Surely the unix scheme of using the file mode permissions to determine if its executable and then looking at the contents of the file to determine its type is superior as it avoids problems caused by files having incorrect extensions.

Any thoughts on this matter would be appreciated.
 
Because of Windows legacy... Windows used to run under MS-DOS. DOS commands had extension ".com". There are also DOS Batch files (a bit like shell scripts) with extension ".bat"

And finally, Windows programs have extension ".exe"
 
apatterno

BTW these extension aer not restricted to Windows, MAC has thos extensions also.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Yes. Windows uses a registration mechanism as well so that applications can "register" with the OS to handle the "execution" of a file based on the extension. Of course the file is not actually executing, your app is executing and is passed the file name on the command line by the OS.

This is how it looks like the script file extensions are executing (.js,.vbs,.. any others? ) but really they are just handed to the scripting engine.

-pete

 
.com are executable files limited to 64k of size
.exe are executable files with no size limit
.bat are Batch file to script program execution...

.com was the original executable... (it contained no header, just executable code)

then computers advanced and so did the programs, along with there size...

.exe's were created and contain a header to give an explaination of the file data to the OS...

the header is how the operating system knows what OS the program was written for as well as other data...

this is why, in the DOS days, if you tried to run a windows program in DOS, you would get an error telling you that it was a windows executable...

Batch files were created to save steps in typing...

if you have a program that has command line options like
myprogram.exe -run -help

you can open up a text editor and type that in and then save the file as a .bat file, so next time instead of typeing all of the options and what not... you just type the name of the batch file and press enter...

.com files are usually written in Assembly language, or other low level languages...

.exe are usually written in C/C++, Basic, Pascal, and other High level languages...

and if you are REALLY smart, or just have a lot of time on your hands, you can get a Hex Editor and directly enter the HEX CODES (machine code) for a program and save it as a .com and execute it... where you probably would not want to even try that with an EXE...

.COM and .EXE files are Binary Files
.BAT files are TEXT Files

.exe's WERE NOT CREATED FOR WINDOWS... they were also the main executables in DOS, OS2, MAC, WIN 3.1, WIN 9X, WIN CE, and pretty much every other OS, This does not mean that the all work on all of the systems... since every operating system has different OP Codes... Which is actually the reason Java and HTML were created, now you have universal binary files and html text files that a java virtual machines and web browsers interpret on most of the platforms the same way...

Hope this clears a few things up...

Have Fun, Be Young... Code BASIC
-Josh Stribling
cubee101.gif

 
>> applications can "register" with the OS to handle the "execution" of a file based on the extension.

Yes, this is what I meant to say.

If you look under HKEY_CLASSES_ROOT, at the 'exefile' type, you will see its open command is simply "%1" which means that when the file is double-clicked, the shell will execute the file.

If you look at the VBS script type, it will be something like C:\WINNT\WSCRIPT.EXE "%1"

which causes the shell to run wscript.exe, passing the file's path as a command-line parameter.

Will
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top