Skip to content
⌘ NSIS Forum Archive

Option to disable multiple instances?

7 posts

DOCa Cola#

Option to disable multiple instances?

hi

how can i make my setup executable only one time simultaneously? i mean, when somebody accidently tries to open the setup a second time that nothing happens

thx in advance

DOCa Cola
Joost Verburg#
You can use FindWindow or write a registry key. Because of the race condition, it will in theory be possible to run 2 installers (in 0,0001% of the situations) 😁

The really good way is to use a kernel mutex, maybe you can call CreateMutex with the System plugin. But for a simple check, that might be a bit overkill.
DOCa Cola#
thx for the quick response
i have tried FindWindow, but the problem is, that the first opened window is same declared as the second one. i don't really like the idea of a registry entry, because when the installer fails one time, a user can never run the setup again.

and the kernel mutex, erm, that sounds a bit to complicated 🙂
Joost Verburg#
Did you put FindWindow in .onInit? In .onInit, the window has not yet been created.

For the registry key, you can also write the $PARENTHWND and use IsWindow to see if it's still active.
DOCa Cola#
Hm, yep that works
but not for the installer that uses "SilentInstall silent", any suggestions?