Archive: Problem avoiding setup to run more than once at the same time


Problem avoiding setup to run more than once at the same time
  Hi !

I want to avoid my setup running more than once at the same time. I have tried to use both Findproc and kernel32 to find if my setup is already running or not. I have placed the code in my .oninit function. The problem is that when the setup is launched, it detects itself as running, and so it says me "I'm already running!" Is there a way to make it work? Thx !


System::Call 'kernel32::CreateMutexA(i 0, i 0, t '$(^Name)') i .r1 ?e'
Pop $R0
StrCmp $R0 0 +3
MessageBox MB_OK "The installer is already running."
Abort

or

FindProcDLL::FindProc "myinstall.exe"
StrCmp $R0 1 RunningInst_found RunningInst_notfound
RunningInst_found:
MessageBox MB_OK "The installer is already running."
Abort
RunningInst_notfound:

Language strings are not yet set in .onInit. I recommend you to replace $(^Name) by a unique string that contains a GUID.


Ok thank you for the information. I gave it a try but it still doesn't work. It says that install is running everytime. What can be wrong?


I have defined a unique string

LangString unique_string${LANG_FRENCH} "French"

>;here is the code in .oninit
>Function .oninit
System
::Call 'kernel32::CreateMutexA(i 0, i 0, t '$(^unique_string)') i .r0 ?e'
>Pop $R0
StrCmp $R0 0+3
MessageBox MB_OK "The installer is already running."
>Abort
FunctionEnd
>

When we mean a unique string, we mean a string that is the same for all languages (e.g. NOT a language string).

;I have defined a unique string
!define MutexString "blah blah"

;here is the code in .oninit
Function .oninit
System::Call 'kernel32::CreateMutexA(i 0, i 0, t '${MutexString}') i .r0 ?e'
Pop $R0
StrCmp $R0 0 +3
MessageBox MB_OK "The installer is already running."
Abort
FunctionEnd


-Stu

Thank you again for your rapidity and for the accuracy of your answers ;)