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.
Asked
Active
Viewed 286 times
0

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

Inside Man
- 4,194
- 12
- 59
- 119
-
Related: https://stackoverflow.com/q/28628699/7571258 – zett42 Nov 02 '22 at 12:28
1 Answers
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