This should be simple, I need to stop any previous version of my program from running when the installer starts.
Most people suggested making an exe wh
I have had success using WMIC :
procedure CurStepChanged(CurStep: TSetupStep);
var
ResultCode: Integer;
wmicommand: string;
begin
// before installing any file
if CurStep = ssInstall then
begin
wmicommand := ExpandConstant('PROCESS WHERE "ExecutablePath like ''{app}\%%''" DELETE');
// WMIC "like" expects escaped backslashes
StringChangeEx(wmicommand, '\', '\\', True);
// you can/should add an "if" around this and check the ResultCode
Exec('WMIC', wmicommand, '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
end;
end;
You can also do it in the InitializeSetup but if you do, keep in mind you don't have yet access to the {app} constant. My program doesn't ask for install path, but yours might.