Executable Extensions

Normally, when you type a filename (as opposed to an alias or internal command name) as the first word on the command line, TCC looks for a file with that name to execute.


The file's extension may be .EXE to indicate that it contains a program; .LNK to indicate that it contains information on how to execute a program under Windows; or .BTM, .BAT, or .CMD to indicate a batch file.


You can add to the default list of extensions, and have TCC take the action you want with files that are not executable programs or batch files. The action taken is always based on the file's extension. For example, you could start your text editor whenever you type the name of a .DOC file, or start your database manager whenever you type the name of a .DAT file.


Windows also includes the ability to associate file extensions with specific applications. See Windows File Associations for details on this feature and its relationship to executable extensions. See also: Executable Files and File Searches.


You use environment variables to define the internal command, external program, batch file, or alias to run for each defined file extension. To create an executable extension for use only in TCC, use the SET command to create a new environment variable. An environment variable is recognized as an executable extension if its name begins with a period.


The syntax for creating an executable extension is:


set .ext[;.ext[;...]]=command [options]


where .EXT is the executable file extension; command is the name of the internal command, alias, external program, or batch file to run; and [options] are any command line startup options you want to specify for the program, batch file, or alias. You can specify multiple extensions for a single command by separating them with semicolons.


For example, if you want to run a word processor called EDITOR whenever you type the name of a file that has an extension of .EDT, you could use this command:


set .edt=c:\edit\editor.exe


If the command specified in an executable extension is a batch file or external program, TCC will search the PATH for it if necessary. However, you can make sure that the correct program or batch file is used, and speed up the executable extension, by specifying the full name including drive, path, filename, and extension. You can utilize other environment variables in the specification.


Once an executable extension is defined, any time you name a file with that extension as a command, it is equivalent to having typed the value of the extension variable, followed by the name of the file.


The next example defines WORDPAD.EXE (a Windows editor) as the processor for .TXT files:


set .txt="c:\program files\accessories\wordpad.exe"


Now, if you have a file called HELLO.TXT and enter the command




TCC will execute the command:


"c:\program files\accessories\wordpad.exe" c:\source\hello.txt


Notice that the full pathname of HELLO.TXT is automatically included. If you enter parameters on the command line, they are appended to the end of the command. For example, if you changed the above entry to:


[c:\source] hello -w


TCC would execute the command:


"c:\program files\accessories\wordpad.exe" c:\source\hello.txt -w


In order for executable extensions to work, the command, program, batch file, or alias must be able to interpret the command line properly. For example, if a program you want to run doesn't accept a file name on its command line as shown in these examples, then executable extensions won't work with that program.


Executable extensions may include wildcards, so you could, for example, run your text editor for any file with an extension beginning with T by defining an executable extension called .T*. Extended wildcards (e.g., DO[CT] for .DOC and .DOT files) may also be used.


To remove an executable extension, use UNSET to remove the corresponding variable.