I'm becoming more confused. With no regard to TCMD ... CTRL_CLOSE_EVENT is sent to a console CtrlHandler (like CTRL_C_EVENT and CTRL_BREAK_EVENT). Stand-alone TCC apparently catches it since it triggers the running of TCEXIT.BTM (probably among several other actions). Why, in a stand-alone TCC, can't it trigger some ON condition?CTRL_CLOSE_EVENT sets the ON CLOSE flag. But that wasn't what you asked for -- closing the console window is not the same as closing TCC.
Now this is interesting. If I putAs I said, you can use ON CLOSE. But you probably won't be able to do anything with it, because your session is being killed. (You can't prevent the session from ending, and you can't delay it.)
in my BTM and X the console while it's running, I get both beeps with 4 seconds in between. But what I really want to happen, (and reckon should take much less than 4 seconds), namelyon close (beep & delay 4 & beep & quit)
doesn't work at all. (???)on close (taskend /f %startpid1 & taskend /f %startpid2 & quit)
works just fine.on break (taskend /f %startpid1 & taskend /f %startpid2 & quit)
I don't use a TCEXIT. What then? As I said before, I can "beep & delay 4 & beep" in ON CLOSE, but I can't "taskend %_startpid & quit". In that second case, taskend just seems to hang, doing nothing, until ~5 seconds have elapsed and TCC is terminatedThere are two things that happen when you X the console:
1) TCC will run any ON CLOSE argument
2) TCC will run TCEXIT and exit the app
Note that these will run *simultaneously*, so unless you somehow synchronize their operation you will not have a happy result.
Well, it's no big deal. My immediate concern was terminating some STARTed processes and that's more easily handled with a job object (with /K working).
That said, it doesn't work any better in a TCMD tab. All in all, ON CLOSE seems rather undependable.
It has been by belief that after CTRL_CLOSE_EVENT, Windows gives a console app 5 seconds (unmolested) to perform cleanup. If TCC is dismantling itself, and unloading modules before the ON CLOSE is run, I don't think Microsoft will be able to help me.As with your 100 other posts on the same topic, you should file a complaint with Microsoft. It's conhost.exe that's in control of all of that, not TCC.
It has been by belief that after CTRL_CLOSE_EVENT, Windows gives a console app 5 seconds (unmolested) to perform cleanup. If TCC is dismantling itself, and unloading modules before the ON CLOSE is run, I don't think Microsoft will be able to help me.