1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Documentation Questions re: ON

Discussion in 'Support' started by Steve Fabian, Oct 12, 2013.

  1. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    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?
     
  2. vefatica

    Joined:
    May 20, 2008
    Messages:
    8,060
    Likes Received:
    30
    ON CLOSE does what the help says.
     
  3. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    10,026
    Likes Received:
    84
    Both.

    The help is correct.

    I have no idea what you're asking.
     
  4. Rodolfo

    Joined:
    May 20, 2009
    Messages:
    216
    Likes Received:
    0
    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. Joe Caverly

    Joined:
    Aug 28, 2009
    Messages:
    697
    Likes Received:
    8
    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
     
  6. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    10,026
    Likes Received:
    84
    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. vefatica

    Joined:
    May 20, 2008
    Messages:
    8,060
    Likes Received:
    30
    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. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    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.
     
  9. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    10,026
    Likes Received:
    84
    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. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    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?
     
  11. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    10,026
    Likes Received:
    84
    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.

    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

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    Steve Fabian wrote:
    Rex Conn wrote:
    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:
    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 ?
     
  13. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    10,026
    Likes Received:
    84
    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.

    No.
     
  14. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    Thanks for the valuable information.
     

Share This Page