19

I have seen that every executable file in Windows has an extension of .exe. But Mac OS X doesn't have the same.

Windows executes .exe files. Then what kind of files does Mac OS X execute?

What is the difference between both operating system's execution of applications?

Even I found that windows setups has the same extension .exe but on a Mac setups have extension of .dmg

Would you please share your knowledge with me about .dmg & executables on Macs vs. Windows?

4 Answers 4

22

Extensions don't actually change what type of file something is, although they often do hint to the system what do do with a particular item.

DMGs are not executables, they are disc images. They are files that act as discs, which often contain the executables and other files for applications. When you double-click on one, the system mounts it and you then have access to the files inside.

Both Windows and OS X execute binary executable files, although they are in different formats. The big difference in what a user sees if using the GUI is that on Windows, you usually see the .exe executable file, which resides in a folder that contains other files and information that the program uses. On OS X, all those other files, along with the primary executable, are contained in a "bundle" (really a folder) with the extension .app. Double clicking on a .app bundle will execute the internal executable and load your application.

Outside of the GUI, in the actual file structure, Mac and Windows systems are really quite similar; these differences are mostly a question of how the system presents things to the user for manipulation in the GUI.

6
  • Mac also executes .pkg (package) files
    – Joshkunz
    Oct 17, 2009 at 21:45
  • 2
    .pkg files are compressed bundles of files containing an executable and other installer data, kind of a like a fully-contained, compressed .app that is intended for intallation.
    – phoebus
    Oct 17, 2009 at 21:47
  • 3
    .pkg files are actually technically documents for Installer.app. If they actually run as a separate program they are not true .pkgs.
    – Chealion
    Oct 17, 2009 at 23:35
  • True, I could have been clearer on that point.
    – phoebus
    Oct 18, 2009 at 0:11
  • @phoebus - So to be clear, a .pkg is a file, as in something I can offer for users to download from my website, and not a folder, as in something that I can not offer users to download from my website? Feb 18, 2016 at 20:39
6

.dmg files are the disk image files normally used to install Mac apps. Once installed, Mac apps usually have the extension of .app, but that extension is normally hidden from the user. Mac apps are packages which appear to the user as a single file. This makes it very convenient to move apps to a new folder or a new computer.

4

You will also be able to execute any file that has it's permissions set to executable, given that it actually contains a valid program of course.

1
1

every executable file in Windows has extension of .exe

This is not correct. In DOS there were 2 executable file extensions: *.COM and *.EXE. Windows inherited those so it also supports *.com and *.exe. Note that *.exe is just the "container" that contains various executable formats

If you run a command without an extension Windows will append the extensions in the %pathext% environment variable and search until it find the first file with that name. The default value of the variable is like this

>echo %pathext%
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

As you can see there are other executable file types that Windows will run (without an extension), but most of them are scripts and not binary executables

Nevertheless Windows doesn't actually uses the file extension to determine the file format. Any files beginning with MZ (which is the signature for the MZ format) will be treated as an executable file

In summary classic Windows executable can be

But depending on Windows version some of those formats may not be executable

Windows 10 also has the ability to run Linux ELF binaries with the introduction of

Setup files in Windows are also often provided in *.msi files which a format read by Windows Installer, although strictly speaking it's not a executable file

3
  • 1
    MSIs and JS files are executable, but not executables. MSI is an installer package: when you double click it, msiexec.exe starts and opens it, just like you could use Paint to open JPEGs - it doesn't make them an executable. So with JS, WScript.exe is used to open them (check the HKCU branch in your registry). BATs and CMDs are somewhere in between, one could argue if they are executable - they are natively supported by Explorer, but still have to be interpreted.
    – gronostaj
    Aug 29, 2013 at 19:15
  • in that manner .NET exe files aren't "executables" too because they can only run under .NET framework, not directly by the CPU
    – phuclv
    Aug 30, 2013 at 0:39
  • 1
    It depends how you define 'executability'. I believe MSIs are without any doubt not executable, because they are just an archive - optimized for installers, but it doesn't matter in this case. They aren't more executable than ZIPs. Scripts of any kind are on the edge of 'executability', because they need an interpreter. I don't know details on how .NET EXEs are executed, but I'd say they are the same case as CLASS - they contain some kind of machine code (that needs translation/interpretation, but still).
    – gronostaj
    Aug 30, 2013 at 5:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .