.exe#P3

{{Short description|Filename extension}}

{{Other uses|Exe (disambiguation){{!}}Exe}}

{{Use dmy dates|date=January 2023|cs1-dates=y}}

{{Infobox file format

| name = Windows Executable File

| icon = File:Windows 11 executable.svg

| screenshot =

| extension = .exe

| mime = application/vnd.microsoft.portable-executable

| magic = 0x4d 0x5a

| owner = Microsoft

| type = Executable file

| genre = Executable (Binary machine code)

| container_for = MZ, NE, LX, LE, PE, PE32+, W3, W4, DL, MP, P2, P3

| website =

| open = No

| url =

}}

For Microsoft Windows, OS/2, and DOS, .exe is the filename extension that denotes a file as being executable {{endash}} a computer program {{endash}} containing an entry point.{{cite web|url=https://fileinfo.com/extension/exe|title=.EXE File Extension|website=FileInfo - The File Extensions Database|publisher=Sharpened Productions|access-date=16 August 2019}}

In addition to being executable (adjective) such a file is often called an executable (noun) which is sometimes abbreviated as EXE.

File formats

The file format of an EXE file varies by operating system version.

An operating system cannot use an EXE file unless it is formatted for it. Note that some formats support multiple operating systems.

= {{anchor|MZ|NE}}DOS =

;16-bit DOS MZ executable (MZ): The original DOS executable file format. These formats can be identified by the letters "MZ" at the beginning of the file in ASCII. Later formats may contain an MZ DOS stub header.

;16-bit New Executable (NE): Introduced with the multitasking MS-DOS 4.0 and also used by 16-bit OS/2 and Windows, NE can be identified by the "NE" in ASCII.

= OS/2 =

{{anchor|LX|LE}}

;32-bit Linear Executable (LX): Introduced with OS/2 2.0, these can be identified by the "LX" in ASCII. These can only be run by OS/2 2.0 and higher.{{cite web|url=http://www.operating-system.org/betriebssystem/_english/bs-os2.htm|title=OS/2 Operating System|date=3 April 2004|access-date=13 February 2014|work=operating system documentation project}}

;Mixed 16/32-bit Linear Executable (LE): Introduced with OS/2 2.0, these can be identified by the "LE" in ASCII. {{br}}VxD drivers on Windows 3.x and Windows 9x also use LE format.

= Windows =

{{anchor|PE|PE32+}}

;32-bit Portable Executable (PE): Introduced with Windows NT, they are fat binaries consisting of a DOS-specific and a Windows-specific part. The DOS-specific part (dubbed DOS stub) is a legitimate 16-bit DOS program. Microsoft C++ linker, by default, uses a minimal DOS stub that prints the following message: "This program cannot be run in DOS mode." Windows ignores the DOS stub and executes the Windows-specific portion that starts with the "PE\0\0" ASCII sequence (letters "PE" and two null bytes). With some linkers, it is possible to specify a custom DOS stub. Indeed, there are a few dual programs, such as regedit in Windows 95 and old versions of WinZIP self extractors.

;64-bit Portable Executable (PE32+): Introduced by 64-bit versions of Windows, this is a PE file with wider fields. In most cases, code can be written to simply work as either a 32 or 64-bit PE file. This file also includes a DOS stub.

= Other =

{{anchor|W3|W4|DL|MP|P2|P3}}

There are other EXE formats, including but not limited to W3 (a collection of LE files, only used in WIN386.EXE), W4 (a compressed collection of LE files, only used in VMM32.VXD), DL, MP, P2, P3 (last three used by Phar Lap extenders).{{cite web|url=http://www.ctyme.com/intr/rb-2939.htm#table1593|title=Int 21/AH=4Bh|first=Ralf|last=Brown|website=Ralf Brown's Interrupt List|date=16 July 2000|access-date=30 October 2018|archive-url=https://web.archive.org/web/20150519112524/http://www.ctyme.com/intr/rb-2939.htm#table1593|archive-date=19 May 2015|url-status=dead}}

See also

References

{{Reflist|refs=

{{Cite web |url=https://learn.microsoft.com/en-us/windows/win32/debug/pe-format |title=PE Format |website=Windows App Development |publisher=Microsoft |date=25 August 2019}}

{{cite web |url=https://learn.microsoft.com/en-us/cpp/build/reference/stub-ms-dos-stub-file-name |title=/STUB (MS-DOS Stub File Name) |work=C/C++ Building Reference |edition=Visual Studio 2022 |publisher=Microsoft |access-date=10 January 2014}}

{{cite web |url=http://thestarman.pcministry.com/asm/debug/DOSstub.htm |title=DOS Stub Program |website=The Starman's Realm |publisher=Self-published |first=Daniel B. |last=Sedory |date=12 October 2004 |access-date=10 January 2014}}

{{cite web |url=http://support.microsoft.com/kb/131352 |title=Using Registry Editor in Real Mode |work=Support |publisher=Microsoft|access-date=10 January 2014 |date=15 November 2006|archive-url=https://web.archive.org/web/20140115050101/http://support.microsoft.com/kb/131352|archive-date=15 January 2014 |quote=Windows 95 includes a Registry Editor program (Regedit.exe) that runs in both the real-mode MS-DOS environment and in the protected-mode Windows environment. When you need to modify the registry without starting Windows 95, use Registry Editor in real mode. Note that the switches listed in this article only work in real-mode.}}

{{cite web|url=http://purl.net/xyzzy/dos/dostub.htm|title=dostub.exe|first=Frank |last=Ellermann|website=Purl.net|date=22 January 2014|access-date=24 January 2014}}

{{Cite journal |url=https://msdn.microsoft.com/en-us/magazine/bb985992(printer).aspx|title=An In-Depth Look into the Win32 Portable Executable File Format |journal=MSDN Magazine |publisher=Microsoft |date=February 2002 |first=Matt |last=Pietrek |author-link=Matt Pietrek}}

}}

Further reading

  • {{cite newsgroup |title=Re: Run a COM file |author-first=Matthias R. |author-last=Paul |date=7 October 2002 |orig-year=2000 |newsgroup=alt.msdos.programmer |url=https://groups.google.com/d/msg/alt.msdos.programmer/d7blJjY0H5M/Qu3VeTOIGVcJ |access-date=3 September 2017 |url-status=live |archive-url=https://archive.today/20170903230312/https://groups.google.com/forum/%23!msg/alt.msdos.programmer/d7blJjY0H5M/Qu3VeTOIGVcJ |archive-date=3 September 2017}} [https://groups.google.com/d/msg/alt.lang.asm/PNOd9zfYow0/vXbab16j4XwJ Second reply]