Documentation Questions re: ON

#1
HELP -> ON states "ON CLOSE will execute command when the TCC tab is closed." Is this correct, or does it execute command when a stand-alone TCC window (not in TCMD) is closed?

"ON RESUME" and "ON SUSPEND" warn of not being available in TCC/LE, but neither "ON LOGOFF" nor "ON SHUTDOWN" have that warning. Is this correct? (I am not suggesting any code change!!!)

Closing all JPsoft windows is part of logging off; logging off is part of shutting down, and shutting down is part of both rebooting and powering off. Are the commands associated with ON CLOSE, ON LOGOFF and ON SHUTDOWN executed when those actions take place as part of a more comprehensive action?
 

rconn

Administrator
Staff member
May 14, 2008
10,406
95
#3
HELP -> ON states "ON CLOSE will execute command when the TCC tab is closed." Is this correct, or does it execute command when a stand-alone TCC window (not in TCMD) is closed?
Both.

"ON RESUME" and "ON SUSPEND" warn of not being available in TCC/LE, but neither "ON LOGOFF" nor "ON SHUTDOWN" have that warning. Is this correct? (I am not suggesting any code change!!!)
The help is correct.

Closing all JPsoft windows is part of logging off; logging off is part of shutting down, and shutting down is part of both rebooting and powering off. Are the commands associated with ON CLOSE, ON LOGOFF and ON SHUTDOWN executed when those actions take place as part of a more comprehensive action?
I have no idea what you're asking.
 
May 20, 2009
230
1
53
ITALY
#4
I have no idea what you're asking.
I believe that he means this.
When I log off, automatically all software is closed.
So, if I have specified two different actions for ON CLOSE and for ON LOGOFF, when I log off both actions are performed? Or only the ON LOGOFF one?

Regards

Rodolfo Giovanninetti
 
#5
I believe that he means this.
When I log off, automatically all software is closed.
So, if I have specified two different actions for ON CLOSE and for ON LOGOFF, when I log off both actions are performed? Or only the ON LOGOFF one?
The following .btm file tests for CLOSE and SHUTDOWN;

Code:
@setlocal
@echo off
on close echo ::Closed %_date %_time >> c:\utils\ontest.btm
on shutdown echo ::Shutdown %_date %_time >> c:\utils\ontest.btm
input X the console:  %%fname
endlocal
::Shutdown 10/13/13 10:04:33
Thus, if testing for CLOSE and SHUTDOWN, CLOSE is not executed, but SHUTDOWN is.

Modify code to test for other ON conditions, and see what gets executed, and what does not get executed.

Joe
 

rconn

Administrator
Staff member
May 14, 2008
10,406
95
#6
I believe that he means this.
When I log off, automatically all software is closed.
So, if I have specified two different actions for ON CLOSE and for ON LOGOFF, when I log off both actions are performed? Or only the ON LOGOFF one?
ON CLOSE is triggered when Windows sends a CTRL_CLOSE_EVENT.

ON LOGOFF is triggered when Windows sends a CTRL_LOGOFF_EVENT.

ON SHUTDOWN is triggered when Windows sends a CTRL_SHUTDOWN_EVENT.

The order and combination is determined by Windows, not TCC. If you want details, you'll have to ask Microsoft (or try it yourself).
 
#7
Steve Fabian said:
HELP -> ON states "ON CLOSE will execute command when the TCC tab is closed." Is this correct, or does it execute command when a stand-alone TCC window (not in TCMD) is closed?

Rex replied:
Both.

When I tried it yesterday it didn't work in a console. There must have been a bug because it works today ... good!
 
#8
What's the relationship of the "ON condition" (where condition is one of those which result in termination of the TCC instance) to the execution of TCEXIT? It seemed that in some tests the type of termination determined which is executed, but - IIRC - never both. Different results using the "close window" button (X in upper right corner) vs. TASKEND/F command in a different TCC instance.
 

rconn

Administrator
Staff member
May 14, 2008
10,406
95
#9
What's the relationship of the "ON condition" (where condition is one of those which result in termination of the TCC instance) to the execution of TCEXIT?
None. TCEXIT is run when TCC is shut down from within TCC, or if it receives a WM_ENDSESSION message from Windows. TCEXIT has no relationship with any of the ON commands.
 
#10
Rex:
Based on your responses above, to capture ALL terminations of TCC one needs all of TCEXIT, and ON CLOSE, and ON LOGOFF, and ON SHUTDOWN activated. Are there other conditions (excluding catastrophic system failure, including loss of power, or forced computer power off) that can terminate TCC?
 

rconn

Administrator
Staff member
May 14, 2008
10,406
95
#11
Rex:
Based on your responses above, to capture ALL terminations of TCC one needs all of TCEXIT, and ON CLOSE, and ON LOGOFF, and ON SHUTDOWN activated.
That's not quite what I said. Those actions are all independent; there is some overlap but you can't predict which one will be invoked first.

Also, if the session is ending you've only got about 4 seconds to do everything you want; after that Windows kills the process without waiting for it to complete.

Are there other conditions (excluding catastrophic system failure, including loss of power, or forced computer power off) that can terminate TCC?
Yes, another app can call the TerminateProcess API. Or a third-party dll can inject itself into TCC.EXE and force it to exit. Or the desktop where TCC is running can be closed. Or a device driver can crash.
 
#12
Steve Fabian wrote:
Based on your responses above, to capture ALL terminations of TCC one needs all of TCEXIT, and ON CLOSE, and ON LOGOFF, and ON SHUTDOWN activated.
Rex Conn wrote:
That's not quite what I said. Those actions are all independent; there is some overlap but you can't predict which one will be invoked first.

Also, if the session is ending you've only got about 4 seconds to do everything you want; after that Windows kills the process without waiting for it to complete.
No, you did not say that; I pieced together that to detect at least five (5) of the ways TCC can be closed (in contrast to just killing the its process) one has to have those four (4) detection mechanisms active. Since all I want to do is to record in a usage log the when and why, the 4s limit should be nearly always enough. The overlap (i.e., that more than one condition can occur due to a single event) is not significant for me.

Rex Conn wrote:
Yes, another app can call the TerminateProcess API. Or a third-party dll can inject itself into TCC.EXE and force it to exit. Or the desktop where TCC is running can be closed. Or a device driver can crash.
Does TCC's TASKEND command call the TerminateProcess API? Does such a call send a "request to exit" message to TCC or does it just terminate the TCC process (providing the sending process has the required authority) ? Does closing the desktop send a message to TCC to quit, or just ?
 

rconn

Administrator
Staff member
May 14, 2008
10,406
95
#13
Does TCC's TASKEND command call the TerminateProcess API? Does such a call send a "request to exit" message to TCC or does it just terminate the TCC process (providing the sending process has the required authority) ?
If you use the /F option, TASKEND calls the TerminateProcess API and kills the TCC process immediately (and without notification or recourse). If you don't use /F, TASKEND sends a message to TCC asking it to shut down.

Does closing the desktop send a message to TCC to quit ?
No.