Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!eecae!netnews.upenn.edu!rutgers!bellcore!faline!thumper!ulysses!mhuxo!mhuxu!att!cbnews!shurr From: shurr@cbnews.ATT.COM (Larry A. Shurr) Newsgroups: comp.sys.ibm.pc Subject: Re: Execution Order Keywords: COM EXE BAT Message-ID: <4283@cbnews.ATT.COM> Date: 23 Feb 89 19:09:06 GMT References: <992@expya.cs.exeter.ac.uk> Reply-To: cbema!las@cbnews.ATT.COM (Larry A. Shurr) Organization: AT&T Bell Laboratories (actually an AGS consultant) Lines: 38 In article <992@expya.cs.exeter.ac.uk> sru@cs.exeter.ac.uk (Steve Rush) writes: [Wants to be able to selectively induce a .EXE file to be executed in preference to a .COM file having the same name] > The reason for asking is that there are several EXE files no our >machines and I want to do some preprocessing before the actual program >is run (eg. to check parameters before running 'dangerous' software, ie >check which drive has been specified before running FORMAT). My idea >was to write a FILE.COM file which did my preprocessing and then run >FILE.EXE to run the actual program. But what happens is that it loops, >continually running my preprocessor !! I have done something like this in that I have a number of programs which preprocess the command line and then run a target program passing the reprocessed command line to it. As it happens, the preprocessor programs are .COM files generated from an assembly language template I wrote and the target programs are (or, were - keep reading) .EXE files, but that's not important. The trick is that I renamed the .EXE files to have the extension .XXX. Since the preprocessor programs "exec" the .XXX files, specifying a fixed pathname to the target program, this works great. You can do this because the loader doesn't care about the filename extension, instead it looks at the first two bytes of the file - if they are the characters "MZ", then it is assumed to be a .EXE file, otherwise, it is assumed to be a .COM file. Because the .EXE files are renamed to a have a new, uninteresting-to-COMMAND.COM extension, they can never be executed inadvertantly, even if you are in the same directory in which they are located. If you do not want to rename the .EXE files - even just to change the extension - or to require the files to be on a specific path then this method will not help you, sorry. regards, Larry -- Signed: Larry A. Shurr (att!cbnews!cbema!las or osu-cis!apr!las) Clever signature, Wonderful wit, Outdo the others, Be a big hit! - Burma Shave (With apologies to the real thing. The above represents my views only.)