0

I need to allow only one instance of Inno Setup. I used SetupMutex, but when I run the second setup it will prompt the user. I need the setup do nothing and close without any prompt, if another instance is running.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Inside Man
  • 4,194
  • 12
  • 59
  • 119

1 Answers1

2

I do not think that what you are trying to do is an improvement to a user experience, quite on the contrary, anyway...


Remove your SetupMutex directive and use this code instead:

[Code]

const
  SetupMutexName = 'MyProgSetup';

function InitializeSetup(): Boolean;
begin
  Result := True;
  if CheckForMutexes(SetupMutexName) then
  begin
    Log('Mutex exists, setup is running already, silently aborting');
    Result := False;
  end
    else
  begin
    Log('Creating mutex');
    CreateMutex(SetupMutexName);
  end;
end;

(There's a negligible chance for a race condition between CheckForMutexes and CreateMutex)

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992