From a batch file, you can determine if TCC-RT is loaded by doing a numeric comparison:
if 01 == 1 echo TCC-RT is loaded!
In TCC-RT, this is a numeric comparison and true; in CMD it is a string comparison and false. Once you have established that the batch file is running in TCC, you can use internal variables like _CMDPROC, _4VER, _DOS, _DOSVER, and _WIN to further determine the operating environment.
You can determine if TCC is running in a Take Command tab window with the internal variable _TCTAB:
if %_tctab == 1 echo TCC is running in a Take Command tab window!
You can prevent your batch file from running in CMD by giving it the .BTM extension. CMD doesn't recognize .BTM files as batch files.