I think you need to think a little about your script before you go ahead. There are many different interpretations of “launching the same program” more than once. For example, you
- Once per car
- Once per login session
- Once per user
They all have different, albeit similar, solutions.
The easiest way to describe for each machine. In this case, you want to create a named Mutex. One start of each program should receive this mutex, if they are successful, they are launched and held on Mutex throughout the entire life cycle of the process. Otherwise, some other program starts and they exit immediately.
Unfortunately, this approach also has its drawbacks. If I want to ruin your program, I can create a mutex with the same name. This will not allow your program to run any instance, because they cannot determine who is holding Mutex, just something is holding the mutex.
Jaredpar
source share