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.

3 Answers
3

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.

Yup, that could do the trick. Of course it’s a real pain and some serious limits like not being runnable from a batch file or the Run dialog. Not being able to copy them sure is frustrating isn’t it? :-(
–
SynetechMay 4 '12 at 0:20

Nope; that is incorrect. The reason that works is because tree.com is not actually a .COM file, it is a .EXE file with a .com extension for backward-compatibility (as are almost all of the .COM files in Windows for quite a few versions now). If it were a true .COM file, it would have been opened with the default “all-files” program, or if none is set, then you would have been prompted with the Open With dialog box.
–
SynetechMay 1 '12 at 8:21

True. Cool. Uncool that a simple type tree.com reveals that is has an MZ exe signature. Doh. So what would be the correct answer? "Not at all"?
–
TheBlastOneMay 2 '12 at 18:43

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.