Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

ON EXIT?

May
13,035
174
Is there an "ON ..." command I can out in a BTM that will be triggered if the user Xs TCC's console or if the BTM itself calls EXIT?
 
The help says
Code:
ON CLOSE will execute command when the TCC tab is closed
with a simple BTM like
Code:
on close beep
dir /s c:\
I haven't been able to see it work at all (tab or stand-alone).
 
I can't find a scenario in which "ON CLOSE" works, either in a console or on TCMD. This one is closer to what I want to do.
Code:
start
on close taskend /f %_startpid
pause
Regardless of where I run it, console of tab, the STARTed process continues to run after Xing the console or tab.

Is there some experiment that will let me see that "ON CLOSE" works at all, especially in a stand-alone console?
 
Vince,
When I run this .BTM from a detached TCC;
Code:
@setlocal
@echo off
on close calc.exe
pause
endlocal

...when I click the X to close TCC, calc.exe launches, and a few seconds later, the TCC window disappears.

Not sure why it does not disappear immediatly, but it does disappear.

Joe
 
All in stand-alone TCC ... This one works (the file is written) when I X the console and it exits immediately.
Code:
on close echo xyz > v:\foo.txt
do forever ( delay 1 )

This one doesn't work (the STARTed TCC isn't killed) and the TCC running the BTM exits 5 seconds after it's X'd.
Code:
start
on close taskend /f %_startpid
do forever ( delay 1 )

It'd be nice if it always worked or if we knew what to expect in various situations. But if Xing the console results in Windows pulling the rug from under TCC both of those might be impossible.
 
TCEXIT is no more reliable after Xing the console. With this TCEXIT.BTM
Code:
beep
taskend /f %_startpid
I get nothing (and no delay) from TCC v22. From TCC v21 I get a beep and a 5 second delay but a STARTed process isn't terminated.
 
I can't find a scenario in which "ON CLOSE" works, either in a console or on TCMD. This one is closer to what I want to do.
Code:
start
on close taskend /f %_startpid
pause
Regardless of where I run it, console of tab, the STARTed process continues to run after Xing the console or tab.

Is there some experiment that will let me see that "ON CLOSE" works at all, especially in a stand-alone console?

This doesn't have anything to do with the ON CLOSE (which is working perfectly), it's because Windows is blocking TASKEND from enumerating the processes to get the window handle for %_startpid. Windows really doesn't like you doing things like that when it's shutting down a process.
 
Back
Top
[FOX] Ultimate Translator
Translate