When TCC-RT can't find a matching internal command name, it tries to find an executable file whose name matches the command name. (Executable files are typically those with an .EXE extension.)
If TCC cannot find an executable program to run, it next looks for a matching batch file name. TCC-RT looks first for a .BTM file, then for a .CMD file, then for a .BAT file, and finally for a .REX, .REXX, .PL, .PY, .RB, or .TCL file (if REXX, Perl, Python, Ruby, and/or Tcl are enabled).
You can change the list of extensions that are considered "executable", and the order in which they are searched, with the PATHEXT environment variable. PATHEXT is supported for compatibility reasons but should not generally be used as a substitute for executable extensions, which are more flexible.
Note: If the search for an external program or batch file fails, TCC checks to see if the command name matches the name of a file with an executable extension. If an executable extension is found, TCC runs the program specified when the association was defined. If no executable extension is found, TCC will look for a direct association for the extension in the registry and insert the associated string (usually the name of an application) at the beginning of the command line, then call the Windows CreateProcess API to execute that command. If the CreateProcess call fails, or if no association was found in the registry, TCC calls the ShellExec Windows API. TCC has no control over which action the above Windows APIs will take when presented with a file name. If you are concerned about what Windows might do with an "unknown" extension, create a specific executable extension.
TCC first performs this search (for an executable program, a batch file, or a file with an executable extension) in the current directory. If that search fails, they repeat the search in every directory in your search path.
The search path is a list of directories that TCC (and some applications) search for executable files. For example, if you wanted TCC to search the root directory of the C: drive, the \WINUTIL subdirectory on the C: drive, and the \UTIL directory on the D: drive for executable files, your search path would look like this:
The directory names in the search path are separated by semicolons.
You can create or view the search path with the PATH command. You can use the ESET command to edit the path. Many programs also use the search path to find their own files. The search path is stored in the environment with the name PATH.
TCC-RT also searches the \WINDOWS\SYSTEM32 directory followed by the \WINDOWS directory. (The actual directory names may be different on your system. TCTCC-RTC will determine the correct names for the "Windows" and "Windows System" directories and use them.) This part of the search procedure conforms with the traditional search sequences used under each Windows operating system.
Note: If the file is not found on the PATH, TCC then checks for a corresponding App Paths entry in the Windows registry. App Paths entries are created by some applications during the installation process.
Remember, TCC always looks for an executable file (or a file with an executable extension or Windows file association) in the current subdirectory, then in the Windows directories if appropriate (see above), then in each directory in the search path, and then in the App Paths area of the registry. (You can change the search order so the current directory is not searched first; see the PATH command for details.)
If you include an extension as part of the command name, TCC only searches for a file with that extension. Similarly, if you include a path as part of the command name, TCC-RT will look only in the directory you specified, and ignore the usual search of the current directory and the PATH.
Once the file is found, TCC executes it based on its extension. .EXE files are executed by passing their names to the operating system. .BTM, .BAT, and (if applicable) .CMD files are executed by TCC-RT, which reads each line in the file as a new command. Files with executable extensions are executed by starting the associated application, and passing the name of the file on the command line.
If you specify a file name including extension, and the file exists in the current directory (or you specify a path), but the file does not have an extension known to TCC-RT (.EXE, .BTM, .BAT, .CMD, or an executable extension), then the file name will be passed to Windows to check for file associations defined in the Windows registry. This allows you to execute any file whose extension is known to Windows, simply by typing its name. For example, if you have no executable extension defined for .PSP files, but this is an extension known to Windows, at the prompt you can simply enter a command like this:
and TCC-RT will request that Windows start the application for you. See Windows File Associations for additional details on how to control Windows file associations in TCC-RT.
The following table sums up the possible search options (the term "standard search" refers to the search of the current directory, the Windows directories, and each directory in the search path):
|Command||TCC Search Sequence|
|WP||Search for any executable file whose base name is WP.|
|WP.EXE||Search for WP.EXE; will not find files with other extensions.|
|C:\WP\WP||Looks in the C:\WP directory for any executable file whose base name is WP. Does not check the standard search directories.|
|C:\WP\WP.EXE||Looks only for the file C:\WP\WP.EXE.|
|LAB.DOC||Search for LAB.DOC, if .DOC is defined as an executable extension. Runs the associated application if the file is found. If .DOC is not an executable extension, passes the name to Windows to check for a Windows file association.|
|C:\LI\LAB.DOC||Looks only for the file C:\LI\LAB.DOC, and only if .DOC is defined as an executable extension. Runs the associated application if the file is found. If .DOC is not an executable extension, passes the name to Windows to check for a Windows file association.|
If the first argument on a command line is in the format "env_var=value command options" (and env_var=value doesn't match an external command) then TCC will set the specified environment variable to the value, execute the command, and then remove the variable.
If TCC-RT cannot find an executable file, batch program, or a file with an executable extension or Windows file association in the current directory, a directory in the search path, or the directory you specified in the command, it then looks for an alias called UNKNOWN_CMD (see the ALIAS command for details). If you have defined an alias with that name, it is executed (this allows you to control error handling for unknown commands). If TCC-RT cannot find an UNKNOWN_CMD alias, it will look for a plugin command named UNKNOWN_CMD. Otherwise, TCC-RT displays an "Unknown command" error message and waits for your next instruction.
See also: the WHICH command.