TCC Startup Program
Each time TCC starts, it looks for a program named TCSTART. TCSTART is normally a batch file (.BAT, .BTM, or .CMD), but it can be any executable file. If you specify a path in the TCSTART / TCEXIT configuration option, the file must be in the specified directory. If the configuration option is not used, the TCSTART program, if any, in the same directory as your command processor is executed. Use of TCSTART is optional, and TCC will not display an error message if it cannot find the program. If you do not want to use a startup program, set the TCSTART / TCEXIT path to a directory which does not have one, or leave it unspecified, and make sure that no matching executable file is in TCC's directory.
TCSTART is a convenient place to change the color or content of the prompt for each session, LOG the start of a session, or execute other special startup or configuration commands. It is also one way to set aliases, functions, and environment variables. See the section below on Pipes etc. about changing directories via TCSTART.
With the exception of some initialization switches, the entire startup command line passed to TCC is available to TCSTART as batch file parameters (%1, %2, etc.). For example, to pause if any parameters are passed, you could include this command in TCSTART:
if %# GT 0 pause Starting %_cmdproc with parameters [%$]
You can disable TCSTART and/or TCEXIT
Pipes, Transient Sessions / Processes, and TCSTART
When you set up the TCSTART program, remember that it is executed every time the command processor starts, including when running a pipe or when a transient copy of TCC is started with the /C startup option. For example, suppose you enter a command line like this, which uses a pipe:
[c:\data] myprog | sort > out.txt
Normally this command would create the output file C:\DATA\OUT.TXT. However, if your TCSTART program changes to a different directory, the output file will be written there, not in C:\DATA. This is because TCC starts a second copy (instance) of itself to run the commands on the right hand side of the pipe, and that new copy executes TCSTART before processing the commands from the pipe.
The same thing occurs if you use a transient session (one started with the /C option) to run an individual command, then exit. The session will execute in the directory set by TCSTART, not the directory in which it was originally started (e.g., by specifying a working directory in a shortcut). For example, suppose you set up a desktop object with a command line like this, which starts a transient session:
|Command:||d:\tc\tcmd.exe /c list myfile.txt|
Normally this shortcut would LIST the file C:\DATA\MYFILE.TXT. However, if TCSTART changes the default to a different directory, TCC will look for MYFILE.TXT there, not in C:\DATA.
Similarly, any changes to environment variables, aliases, or other settings in TCSTART will affect all copies of TCC, including those used for pipes and transient sessions.
You can work around these potential problems with the IF or IFF commands and the _PIPE and _TRANSIENT internal variables. For example, to skip all TCSTART processing when running in a pipe or in a transient session, you could use a command like this at the beginning of TCSTART:
if %_pipe != 0 .or. %_transient != 0 quit
TCC Termination Program
Whenever a TCC session ends, it looks for a program named TCEXIT. TCEXIT is normally a batch file (.BAT, .BTM, or .CMD), but it can be any executable file. The location of this optional program is determined by the same rule as the location of the TCSTART program for the session, and is not necessary in most circumstances. However, it is a convenient place to put commands to save information from one session to another, such as a (command) history list before TCC exits, or to LOG the end of the session. You can use a termination program even if you have no startup program.
No parameters are passed to the termination program.