I have autoex.btm files in relatively few of my directories, but here are some of the uses I make of it.
I have directories for each of the financial institutions that I deal with (banks, credit cards, investment companies). They have autoex.btm files that display a list of the most recent statements. That way, I quickly see which ones are missing and need to be downloaded from the company's website. The output also reminds me of special aliases, such as one for automatically opening the most recent statement in Adobe reader. I can double-click the name of any statement to select it and then click my toolbar RUN button to open it. The script also copies the full path to the clipboard, which is handy when I'm downloading a statement from the website.
For the top-level financial directory, autoex.btm displays a list of all the subdirectories. I can double-click to select one and then click the toolbar "CD/UP" button to change to that directory.
I have directories for each utility (gas, electricity, etc.). The autoex script lists the most recent statement and the name of the spreadsheet I use to keep track of usage. I can double-click the name to select it and then click my toolbar RUN button to execute it.
Each organization for which I volunteer has a directory, and that directory contains subdirectories for various functions. The autoex script displays a list of those directories with their descriptions.
I don't have autoex.btm files in any of the directories accessed during startup, and I've never had a pipe or transient instance of TCC use those directories (but adding your suggested code seems like a good idea). I can't think of any reasonable way to suppress its operation during TCSTART.BTM. Oh, could one test based on %_batchname by adding if "%@name[%_batchname]" EQ "tcstart" quit 1.
Well, of course what I suggested won't work for detecting TCSTART since the batchfile running is cdtests.btm. The parameter %0 also does not work. I'm too tired now (it's almost 1 am) to think this through. Maybe tomorrow.
I don't think the directory changes happen in TCSTART. I think they're just normal start-up stuff. In CDTESTS.BTM I can see how long TCC has been running and not run AUTOEX.BTM if that's less than (say) 2 seconds. I have a couple of plugin ways to get TCC's running time very easily. But, if I had to, I could do it without plugins. That would involve using @WMI to get TCC's start time and the current time, both in the format YYYYMMDDHHMMSS.mmmmmm±ZZZ ... using @INSTR to get dates and times ... turning them into AGES (@MAKEAGE) ... and doing a little math.
I found that UNALIASing the CD_Enter alias at the beginning of my .btm, and then ALIASing the CD_Enter at the end of my .btm, solved alot of my problems.
Not sure if this would help your issues or not.
:: Use with the CD_Enter alias
iff exist %thedir THEN
Thanks, Joe. I like that idea. Since I'm doing things this way: cd_enter=call v:\cdtests.btm && call autoex.btm I can just set a flag at the start of autoex.btm and unset it at the end, and test for it in cdtests.btm.