Reputation: 10055
My Setup.exe created by Inno Setup detects that one of the executable in my installation directly is currently running when i try and install an update.
I select "Automatically close the applications" and press Next. It seems Inno Setup does something to close this application, but it doesn't close it properly.
The system tray icon disappears but the process remains running.
I've no idea how Inno Setup attempts to close this application, but its not working whatever it's doing.
The application has a parameter /exitall
, which closes all instances of this application including itself.
Is there any way to execute a command line command when the Setup.exe is run before Inno Setup detects the running applications?
Upvotes: 1
Views: 630
Reputation: 202242
Use CurStepChanged(ssInstall)
to execute your "kill" command:
procedure CurStepChanged(CurStep: TSetupStep);
var
AppPath: string;
ResultCode: Integer;
begin
if CurStep = ssInstall then
begin
Log('Installing...');
AppPath := ExpandConstant('{app}\MyProg.exe');
if not FileExists(AppPath) then
begin
Log(Format('Application %s was not installed yet.', [AppPath]));
end
else
begin
Log(Format('Application %s is installed, running cleanup procedure...', [AppPath]));
if not Exec(AppPath, '/exitall', '', SW_SHOWNORMAL, ewWaitUntilTerminated,
ResultCode) then
begin
Log('Failed to run cleanup procedure.');
end;
end;
end;
end;
Though a standard way is to use AppMutex
directive to prevent the installer from proceeding before a user closes the application.
Upvotes: 1