sru@cs.exeter.ac.uk (Steve Rush) (02/15/89)
Dear Net, I have a question about execution order in MSDOS. I beleive that commands in MSDOS are executed in the order .COM .EXE .BAT so if there are several files in the directory with the same name but with different extensions it is the .COM file that would be executed. Is there anyway to get MSDOS to execute the .EXE file instead? I have tried typing FILE.EXE but the silly operating system runs the FILE.COM anyway !! (I am using DOS 3.3) 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 !! Any suggestions? I have thought of renaming the program and putting my checks and the call to the actual program inside a batch file but some of the programs complain if I try to run them under a different name. Note, people will often be in the actual directory where the program is located, so I can't cheat by giving a full path name to the EXE file and putting the batch file at the start of the path. Thanks in advance for any suggestions. Steve ----------------------------------------------------------------------- S.Rush sru@uk.ac.exeter.cs University of Exeter ..!ukc!expya!sru Computer Science Dept. Prince of Wales Road, Exeter EX4 4PT.
marc@dbase.UUCP (Marc Schifer) (02/18/89)
In article <992@expya.cs.exeter.ac.uk>, sru@cs.exeter.ac.uk (Steve Rush) writes: > Dear Net, > > I have a question about execution order in MSDOS. I beleive that > commands in MSDOS are executed in the order .COM .EXE .BAT so if there > are several files in the directory with the same name but with > different extensions it is the .COM file that would be executed. > > Is there anyway to get MSDOS to execute the .EXE file instead? > > I have tried typing FILE.EXE but the silly operating system runs the > FILE.COM anyway !! (I am using DOS 3.3) > > 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 !! > > Any suggestions? I have thought of renaming the program and putting > my checks and the call to the actual program inside a batch file but > some of the programs complain if I try to run them under a different > name. Note, people will often be in the actual directory where the > program is located, so I can't cheat by giving a full path name to the > EXE file and putting the batch file at the start of the path. > > Thanks in advance for any suggestions. > > Steve > Try renaming the .EXE file to something else (ie XFILE.EXE) this way you eliminate the looping.(of course it still allows someone to execute the original file on its own.) IF your com file is calling the exe file internaly you may try using some nonstandard characters in the second files name to slow down the average user from accessing the file. hope this helps marc ------------------------------- (Discalimer.-I ain't claiming nothing!) [P.S. Could someone let me know if this is acctualy getting out on to the net.?]
jls@killer.DALLAS.TX.US (Jerome Schneider) (02/20/89)
In article <22@dbase.UUCP>, marc@dbase.UUCP (Marc Schifer) writes: > In article <992@expya.cs.exeter.ac.uk>, sru@cs.exeter.ac.uk (Steve Rush) writes: > > I have a question about execution order in MSDOS. I beleive that > > commands in MSDOS are executed in the order .COM .EXE .BAT so if there > > are several files in the directory with the same name but with > > different extensions it is the .COM file that would be executed. > > [question about circumventing this is deleted] > > Thanks in advance for any suggestions. > > Steve > Try renaming the .EXE file to something else (ie XFILE.EXE) > this way you eliminate the looping.(of course it still allows > someone to execute the original file on its own.) IF your > com file is calling the exe file internaly you may try using > some nonstandard characters in the second files name to > slow down the average user from accessing the file. > hope this helps > marc Steve's observation about the COM EXE BAT search order is correct. When command.com tries to run a program, the extension is stripped off and the three extensions are appended, one at a time, while the PATH is searched for a matching file. The first match found is the file executed. The three extensions are stored near the very end of the COMMAND.COM file and it might be possible to hack command.com to alter the search order, but your problem with the PATH search sequence will reamain. As a side note, the EXE extension on a file is not really used by the loader -- a magic number in the first two bytes identifies a relocatable module, even if it is called foo.bar. However, this trick is probably valid only from a spawn() call that bypasses COMMAND.COM. It would appear, then, that DOS will frustrate any attempts to modify the search sequence. -- Jerome Schneider UUCP: killer!jls.DALLAS.TX.US (guest account) Aspen Technology Group Ft. Collins, CO Voice: (303) 484-8466
dhesi@bsu-cs.UUCP (Rahul Dhesi) (02/21/89)
In article <7237@killer.DALLAS.TX.US> jls@killer.DALLAS.TX.US (Jerome Schneider) writes: >Steve's observation about the COM EXE BAT search order is correct. When >command.com tries to run a program, the extension is stripped off and the >three extensions are appended, one at a time, while the PATH is searched >for a matching file. However, I remember seeing an article here from somebody at Microsoft (Len Fisher, was it you?) that contained excerpts from an internal customer support memo. It explained that the execution search algorithm was not identical in all MS-DOS versions. Some versions strip the extension and some don't. -- Rahul Dhesi UUCP: <backbones>!{iuvax,pur-ee}!bsu-cs!dhesi ARPA: bsu-cs!dhesi@iuvax.cs.indiana.edu
shurr@cbnews.ATT.COM (Larry A. Shurr) (02/24/89)
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.)
madd@bu-cs.BU.EDU (Jim Frost) (02/27/89)
In article <7237@killer.DALLAS.TX.US> jls@killer.DALLAS.TX.US (Jerome Schneider) writes: |As a side note, the EXE extension on a file is not really used by the |loader -- a magic number in the first two bytes identifies a relocatable |module, even if it is called foo.bar. However, this trick is probably |valid only from a spawn() call that bypasses COMMAND.COM. In fact, many commercial packages take advantage of this to make independent modules which are not user-runnable. DisplayWrite III is such a program, using the extension .PRG for each of the modules. jim frost madd@bu-it.bu.edu