/* ntwhich.txt ... find first matching executable in path * Copyright (C) 1994 by * jack j. woehr, p.o. box 51, golden, colorado 80402-0051 * jax@well.sf.ca.us JAX on GEnie 72203.1320@compuserve.com * SYSOP, RealTime Control & Forth Board [RCFB] (303) 278-0364 * All Rights Reserved */ /* * This is free software and can be modified and redistributed under * certain conditions described in the file COPYING.TXT. The * Disclaimer of Warranty and License for this free software are also * contained in the file COPYING.TXT. */ Usage: NTWHICH <-l | -L | /l | /L | -h | -H | /H | /?> [filename, filename, filename, ...] Synopsis: The -l option gives the license. The -h option gives help, as does the /? option. NTWHICH searches the path for the first occurence in the path of an executable consisting of 'filename' plus one of the four command- line-executable extensions, .COM, .EXE, .BAT or .CMD The order in which NT will execute files of the same name with different extensions when found in the same directory is as follows: 1) .COM 2) .EXE 3) .BAT 4) .CMD Therefore, when searching the path, the first occurrence of a pair of identical filenames with different extensions is resolved in the same manner by NTWHICH, e.g., if FOO.COM and FOO.EXE are in the same directory c:\blah\woof as found in the path, C:\>NTWHICH foo will report as follows: FOO: c:\blah\woof\foo.COM NTWHICH accepts multiple filenames. If any filename has an extension on it, e.g., FOO.ARF, that specific file will be sought, but again, only in the path. NOTE: As CMD.EXE has an implicit first element of ".\" (the current directory) since 'way back in the MSDOS days, NTWHICH treats the matter the same way: the current directory is searched first. Bugs: PATH is limited to about 16K characters. The combined filename and any single path element is limited to about 4k characters. This should probably be enough. <>