With the introduction of microcomputers, the type of files commonly associated with the extension .com changed; in 8-bit CP/M, and later in MS-DOS and compatible DOSes, they are binary executable files by convention. However, executables in the COM file format do not have to have the file name extension .COM in any but CP/M and very early versions of MS-DOS.
The .COM file name extension has no relation to the .com (for "commercial") top-level Internet domain name. However, this similarity in name has been exploited by malicious computer virus writers.
Since it lacks relocation information, it is loaded by the operating system at a pre-set address, at offset 0x0100, where it is executed. This was not an issue on early 8-bit machines because of how the segmentation model works, but it is the main reason why the format fell into disuse soon after the introduction of 16- and then 32-bit processors with their much larger, segmented memories.
In Intel 8080 CPU architecture, only 65,536 bytes of memory could be addressed (address range 0x0000 to 0xFFFF). Under CP/M, the first page of this memory, from 0x0000 to 0x00FF was reserved for system use, and any user program had to be loaded at exactly 0x0100 to be executed. COM files fit this model perfectly. Note that there was no possibility of running more than one program or command at a time: the program loaded at 0x0100 was run, and no other.
Although the file format is the same in MS-DOS and CP/M, this does not mean that CP/M programs can be directly executed under MS-DOS or vice versa; MS-DOS COM files contain x86 instructions, while CP/M COM files contain 8080, 8085 or Z80 instructions. Additionally, MS-DOS COM files often depend on operating system traps supplied exclusively by MS-DOS via interrupt 21h. It is possible to construct a fat COM file which both processor families can execute.
Under CP/M 3, if the first byte of a COM file is 0xC9 then this indicates the presence of a 256-byte header; since 0xC9 corresponds to the 8080 instruction RET, this means that the COM file will immediately terminate if run on an earlier version of CP/M that does not support this extension.
Files may have names ending in .COM, but not be in the simple format described above; this is indicated by a magic number at the start of the file. For example, the COMMAND.COM file in DR-DOS 6 is actually in DOS executable format, indicated by the first two bytes being MZ (0x4D 0x5A), the initials of Mark Zbikowski.
foo.com and foo.exe, the following would execute foo.com:C:>foo
If the user wishes to run foo.exe, they can explicitly use the complete filename:
C:>foo.exe
Taking advantage of this default behaviour, virus writers and other malicious programmers sometimes use names like notepad.com for their creations, hoping that if it is placed in the directory of the corresponding EXE file, a run command or batch file may accidentally trigger their program instead of the ubiquitous notepad.exe text editor.
On Windows NT and derivatives (Windows 2000, Windows XP, and Windows Vista), the PATHEXT variable is used to determine the order of preference (and acceptable extensions) for calling files without specifying the extension from the command line. The default value still places .com files before .exe files.
http://www.example.com/, but instead would run the attached binary command file named www.example, giving it full permission to do to their machine whatever its author had in mind.Note that there is nothing malicious about the COM file format itself; this is an exploitation of the coincidental name collision between .com command files and .com commercial web sites.