B4J Question How to launch an external .exe and monitor it...

Discussion in 'B4J Questions' started by Pietro Pancino, May 7, 2019.

  1. Pietro Pancino

    Pietro Pancino Member Licensed User

    Hi all,
    I need to launch and external .exe program and monitor if it's still running in order to relaunch it automaticaly. If anyone have an idea !
    :) Pietro
  2. Erel

    Erel Administrator Staff Member Licensed User

    See jShell library.
  3. sorex

    sorex Expert Licensed User

    you can use tasklist with jShell to see if it's running.

    tasklist /fi "imagename eq java.exe"

    problem is that something writting in B4J runs under the java.exe so it's hard to identify which process is what so you'll have to check on the window title name.
    The same goes for other programs that might start something in the background and close their opening program.

    C:\>tasklist /fi "windowtitle eq Snake Place Level Generator" /v /fo list

    Image Name:   java.exe
    Session Name: Console
    Mem Usage:    
    93 916 K
    Status:       Running
    User Name:    domain\me
    CPU Time:     
    Window Title: Snake Place Level Generator
  4. Erel

    Erel Administrator Staff Member Licensed User

    The ProcessCompleted event will be raised when the program ends.
  5. sorex

    sorex Expert Licensed User

    yes, but only if his own app has started the exe AND if the exe doesn't start another process without waiting for it.

    if he wants to start his checker every 15 minutes via a scheduled task to see if it still runs he can't rely on the processCompleted event.

    if he uses a timer inside his checker app (and keeps the checker app running) he can rely on the processcompleted event but he still needs to check on start if the exe is not already running to prevent misery.
    Last edited: May 8, 2019
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice