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

Pietro Pancino

Member
Licensed User
Longtime 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
 

sorex

Expert
Licensed User
Longtime 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.

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

Image Name:   java.exe
PID:          30000
Session Name: Console
Session#:     1
Mem Usage:    93 916 K
Status:       Running
User Name:    domain\me
CPU Time:     0:00:01
Window Title: Snake Place Level Generator
 
Upvote 0

sorex

Expert
Licensed User
Longtime 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:
Upvote 0
Top