I created a mutex in my application and I have referenced the mutex name in my Installer(.iss) file's [Setup] section. The iss file has a function to uninstall the Application. It uninstalls the application when pressed OK to the uninstall prompt when the Application is not running. When the Application is running, It gives the uninstall prompt, when pressed OK, It throws default message box "Setup has detected My Application is still running. Please close all instances of it now and press OK to continue, or CANCEL to exit." How can I make the above message box suppressible?
Note: I have tried implementing the function InitializeUninstall() to repeatedly check if my application is running and calling function InitializeSetup() when pressed OK to my custom messagebox. But when Cancel is pressed to close the setup (I tried Exit, ExitProcess, Abort, WizardForm.Close when Cancel is pressed.), it throws the default text box I mentioned in first part of the question. I want the latter message box (third image) to be suppressed with Cancel
/////////////////////////////////////////////////////////////////////
function GetUninstallString(): String;
var
sUnInstPath: String;
sUnInstallString: String;
begin
sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppId")}_is1');
sUnInstallString := '';
if not RegQueryStringValue(HKLM, sUnInstPath, 'UninstallString', sUnInstallString) then
RegQueryStringValue(HKCU, sUnInstPath, 'UninstallString', sUnInstallString);
Result := sUnInstallString;
end;
/////////////////////////////////////////////////////////////////////
function IsUpgrade(): Boolean;
begin
Result := (GetUninstallString() <> '');
end;
/////////////////////////////////////////////////////////////////////
function UnInstallOldVersion(): Integer;
var
sUnInstallString: String;
iResultCode: Integer;
begin
// Return Values:
// 1 - uninstall string is empty
// 2 - error executing the UnInstallString
// 3 - successfully executed the UnInstallString
// default return value
Result := 0;
// get the uninstall string of the old app
sUnInstallString := GetUninstallString();
if sUnInstallString <> '' then begin
sUnInstallString := RemoveQuotes(sUnInstallString);
if Exec(sUnInstallString, '/VERYSILENT /NORESTART /SUPPRESSMSGBOXES','', SW_HIDE, ewWaitUntilTerminated, iResultCode) then
Result := 3
else
Result := 2;
end else
Result := 1;
end;
/////////////////////////////////////////////////////////////////////
// InitializeUninstall - event function called during uninstalling
// The code checks if the Utility is open.
// If yes, it gives a prompt to user to close.
//IsAppRunning return true when application is running
function InitializeUninstall(): Boolean;
begin
Result:=True;
while IsAppRunning() do
begin
if MsgBox('{#AppWindowName} is still running.'#13#13'Please close the {#AppWindowName} and press OK to continue. Press Cancel to Exit.', mbError, MB_OKCANCEL) = IDOK then
begin
Result := InitializeSetup();
end
else
begin
Result :=False;
break;
end;
end;
end;


