Companion viruses are very clever. They create a new program with a file name of an existing program. The idea is for the user to attempt to run the program that they normally run, but then run the virus program instead. It can be as simple as taking a program called "game.exe" and creating a virus program called "game.com," to get the "game.com" file to execute by tricking the user. this works really well in DOS based systems or where the user makes use of the "Run..." dialog box in a Windows based environment. This is sometimes called "Spawning."
Companion viruses use a feature of DOS that allows software programs with the same name, but with different extensions, to operate with different priorities. Instead of modifying an existing file, creates a new program which (unknown to the user) is executed instead of the intended program. On exit, the new program executes the original program so that things appear normal. Most companion viruses create a COM file which has a higher priority than an EXE file with the same name.
A companion virus does not attach itself to other programs; rather it infects executable files by creating a companion file with the same name and a .COM extension. Because DOS executes .COM files before .EXE files and .BAT files, the virus loads before the actual program .EXE file and the system appears normal.