How can I run a (16-bit) .COM executable that has been renamed to .COS?

I'm trying to run a couple of 16-bit legacy DOS programs from a standard Windows XP DOS prompt. The problem is that the file extensions have been renamed from .COM to .COS and they are stored on read-only media and I can't copy them (special environment).

Any tips on how to invoke such files despite the weird extension? If they had been 32-bit EXEs, it wouldn't have been an issue running them even without their proper extensions, but with these COM files, I'm unable to find a way to run them.


Look what I can do :-) (just did this in an XP DOS box):

C:\>md test

C:\>cd test

C:\test>xcopy c:\windows\system32\tree.com
C:\windows\system32\tree.com
1 File(s) copied

C:\test>md t1

C:\test>md t2

C:\test>tree
Volume in drive C is OSDisk
Volume Serial Number is 0006EFC4 9654:5A1E
C:.
├───t1
└───t2

C:\test>ren tree.com tree.cos

C:\test>tree.cos
Volume in drive C is OSDisk
Volume Serial Number is 0006EFC4 9654:5A1E
C:.
├───t1
└───t2

C:\test>ren tree.cos newname.cos

C:\test>newname.cos
Volume in drive C is OSDisk
Volume Serial Number is 0006EFC4 9654:5A1E
C:.
├───t1
└───t2

C:\test>

I.e. you obviously can execute cos files if you explicitely name the extension at the DOS prompt.


Ok. I have figured it out. I think, anyway. This takes advantage of the fact that DOS .COM files are just binary images with a 0x100 byte header, with the first couple bytes being a JMP 0x0100 (hopefully I'm right about that) and the old DOS utility debug which exists in XP.

  • open command prompt
  • cd to directory containing .COS files
  • debug enter
  • You are now at the debug.exe prompt (just a dash)
  • Type n{name of your .COS file, including extension} - substituting appropriately. For example, for FILE.COS type nfile.cos, then enter
  • Type l (for load) then enter
  • Type g (for go) then enter

Let me know how that goes. I loaded C:\windows\system32\tree.com but evidently it's really an .EXE (says this cannot be run in DOS mode). Good luck.

(BTW I just read the stuff about tree.com up there, whoops!)


No, I'm afraid that it is not possible to do what you want under the circumstances that you have outlined. Executable files are treated specially (due to their ability to infect a system), so Windows will not let you just run any old file as an executable.

The PATHEXT environment variable tells Windows what programs are "executable" and can be "run", but there are limits. Open a command-prompt and append .cos to pathext and try to run one of the .cos files:

> set pathext=.cos;%pathext%
> foobar.cos

You will see that either the default "all files" program runs, or if none is configured, that the Open With dialog is presented. Why? Because Windows restricts what can be run for safty reasons. You should be able to register .cos files as executable (like .py, .pl, etc.), but even then, it may not be possible since a .py or .pl file is actually just a document that is opened by a program, not an actual executable.

Another option might be to try to create an association whereby you tell the system that .cos files are comfiles. However, the quick test I just attempted did not work and Windows complained that it is not an executable file and returned access denied.