Hi Serge, thank for your interest and you are very kind.
Sorry I forgot to attach Demo6.fmg file.

It's a simple form and without window's title.
I've adapted the new
IsExeRunning2 function to keep retrocompatibility with the current IsExeRunning function. Returning as default, logical value if the current application is already being run in another instance. And when the second parameter was passed, it would return the handle of the instance that was already open.
So, I updated here in attached files:
- Demo6_Exe.rar
- Executable file (updated)
- (1.21 MiB) Downloaded 420 times
- Demo6.rar
- Source files (updated)
- (1.45 KiB) Downloaded 405 times
In that way, we would have a IsExeRunning function improved by
IsExeRunning2.
Improved in my criteria for these reasons:
- In the same way as IsExeRunning, IsExeRunning2 function does not need SET MULTIPLE OFF.
- IsExeRunning2 function works with full name of application. What means that application's full path is being included and it's what ensures that will not confuses with other application with the same name to be different one.
For example: If app with location+name C:\App1\Demo.exe is running and in another instance (other session) other app with location+name C:\App2\Demo.exe be in trying to run... certainly it will be guaranteed. Because this last application even that is with same names are also at different places.
- The IsExeRunning2 function is able to return a preexisting instance identifier of the same application. Behaving differently than IsExeRunning if informed .T. As new and second parameter.
This will allow the programmer to use the handle of the pre-existing instance and manipulate the focus resumption. If the window is minimized, it would restore it and bring it to the front for focus. If the other instance is behind you would only bring it forward and focus.
- Keep retrocompatibility with the pre-existing IsExeRunning function in HMG.
Continuing to answer your questions Serge...
And how about killing the running EXE?
You do not have to kill any process. Just check if it has another session running this same application.
If it is, it only exits (it exits with RETURN) and if not it finds: it continues the application normally.
In case the program got hung up (infinite loop or something)
If got hung up, systems should start again. Because this function is not tied to any temporary file (as it has proposed or indicated by Carlos RD).
IsExeRunning2 it is similar in the aspect of checking app running names. But improved in the way it's done.
Case 3 is best option but then it will bring you back to the EXE you can't get to stop or rerun.
Yes, you will decide what to do if other session is in running in duplication...
Please note that this Demo6 minimizes the window just to simulate that the user left it minimized and tried twice open the app.