nts0699@dsacg1.UUCP (Gene McManus) (09/06/88)
A short while back I posted a problem I was having with the system() function with MSC5.1 while running under DOS4.0. In short, the system() call was failing to kick off a .BAT file which was produced by my program. I thought I was issuing a call that reduced to: system("kyssing.bat"); As it turned out, I was issuing the equivalent of: system("kyssing."); [Note the dot (.) in the string]. This was OK under DOS3.x, but failed under 4.0. I have corrected my problems now, and thanks to those who responded with ideas, help and sample code. Lee Fisher at Microsoft mailed me the following which seems to have general interest to the net: ---------------------------------------------------------------- To: daitc!dsacg1!nts0699 Subject: DOS4.0 & MSC5 system() Date: Sat Sep 03 23:24:37 1988 Gene, FYI: one last thing on this issue: to keep our MS-DOS product support group informed on this, I wrote the following for them, based on the problem you raised. -Lee Fisher leefi@microsof.beaver.washington.EDU {decvax,decwrl,intelca,sco,sun,trsvax,uunet,uw-beaver}!microsof!leefi My opinions are my *OWN*, not those of my employer! Subject: Order of Precedence in Locating Executable Files THis article discusses how COMMAND.COM finds executable files, the order of precedence involved in this search, and how this precedence order can be explicitly overridden in MS-DOS Version 4.00. It also explains the difference in file name recognition of COMMAND.COM and the EXEC system call. COMMAND.COM can execute a file given on it's command line or as a line in a batch file. When a filename is given, whether or not a file extention is supplied with this filename, COMMAND.COM strips off the extention, keeping only the basename of this filename ("FOO" if the file was "FOO.EXE"). Once it has the basename, it looks for an executable file which has this name. The order in which it looks for this is .COM, .EXE, and lastly .BAT. If COMMAND.COM cannot find this file in the current directory of the current drive, it begins searching the directories specified in the environment variable PATH. If such a file is not found, the following error message is displayed: Bad command or file name If there are three files in the current directory, FOO.COM, FOO.EXE, and FOO.BAT, if you try to execute any one of them (by typing "FOO.COM", "FOO.EXE", "FOO.BAT" or just "FOO") COMMAND.COM would only execute FOO.COM, since this is the first one it finds. Beginning with MS-DOS Version 4.00, it is possible to override the order of precedence in which COMMAND.COM looks for files to execute. With this new MS-DOS release, it is possible to explicitly type "FOO.EXE" and have FOO.EXE (not FOO.COM) executed. However, if no filename extention is given, the same order of precedence is used (.COM, .EXE, and .BAT). One side effect of this explicitness is that some incorrect or lax ways of executing a file will no longer work. For example, if the file FOO.BAT exists, typing "FOO." (note there is a period following the base filename, with no extention) will cause MS-DOS to look for the file "FOO.", and it will not find "FOO.BAT". This is a change in functionality from previous releases of MS-DOS. In contrast to COMMAND.COM's method of finding executable files, the MS-DOS interrupt 21h service 4Bh (the EXEC function) does not understand filename extentions. (If a command processor other than COMMAND.COM is used, the order in which executable files are located is specific to the command processor.) The EXEC function simply takes the name of the file specified when invoked and tries to execute it. This lack of filename information is an advantage to programs have files which are executable, but should not be executed by the casual user. Such files are device drivers, which normally have the extention .SYS, or overlay files, which normally have the extention .OVL. COMMAND.COM cannot accidently execute it; only programs that explictly call the EXEC function can run such programs. The EXEC function only understands the files which in most cases have .COM and .EXE extentions. It would not be able to execute a .BAT files; these are specificly "executed", one line at a time, by COMMAND.COM. ---------------------------------------------------------------- Gene McManus @ Defense Logistics Agency Systems Automation Center, Columbus, OH 43215 (614) 238-9403, Autovon 850- UUCP: {uunet!gould,cbosgd!osu-cis}!dsacg1!gmcmanus The views expressed are my own, not those of The Agency, or Dept. of Defense