[VB.NET] Run an application when terminated in Taskmanager

Discussion in 'Mixed Languages' started by jcgo16, Sep 4, 2011.

  1. jcgo16

    jcgo16 MDL Junior Member

    Sep 16, 2010
    74
    2
    0
    Run an application when terminated in Taskmanager

    does anyone know this?

    when i terminate my program using task manager, it will run a program first before it will be killed
     
  2. SS111

    SS111 MDL Novice

    Jul 19, 2011
    30
    2
    0
    #2 SS111, Sep 4, 2011
    Last edited by a moderator: Apr 20, 2017
    Have you tried this?

    Code:
    Private Sub Form1_FormClosed(sender As Object, e As FormClosedEventArgs)
    Process.Start("YOURPROCESSHERE") End Sub
    Make sure you use System.Diagnostics in your imports.
     
  3. jcgo16

    jcgo16 MDL Junior Member

    Sep 16, 2010
    74
    2
    0
    its not working btw, what i meant is, if i closed it using task manager, it will run a program
     
  4. jcgo16

    jcgo16 MDL Junior Member

    Sep 16, 2010
    74
    2
    0
    any more suggestions?
     
  5. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    i dont believe this is possible because task manager just ends executinon it doesn't run through and tell the program it's exiting as in with the close button
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. BobSheep

    BobSheep MDL Guru

    Apr 19, 2010
    2,326
    1,362
    90
    Do you mean an orderly close or kill process? If it's kill process then it's 100% not possible.
     
  7. SiRaDuDe

    SiRaDuDe MDL Novice

    Oct 4, 2011
    9
    1
    0
    #7 SiRaDuDe, Oct 4, 2011
    Last edited: Oct 4, 2011
    If you have 2 applications running, and have one of them keep an eye out for the other then yes, its possible to do something similar, but to run a process just before its killed, I havent a clue. I know you can run a code from an app after a process its killed, if you are keeping tabs on it.

    Your main application must fire both threads on startup.

    I think I played with this a while back, I had a background process always checking for an application to be running.