Hi,
I do it with InnoSetup when i generate a Windows Setup.
To do this, it is based on the GUID (global unique identifier) defined in the InnoSetup script. It is important not to change the code between different application versions and that it is unique. The IDE provided by InnoSetup provides a tool to generate a new one accessible via the menu: Tools> Generate GUID inside the IDE.
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
#define ApplicationGUID "1234687ZE-AAB5-48766-BCD5-FERZAERDS"
#define ApplicationID ApplicationName + "_" + ApplicationGUID
In addition, the installer adds the SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#ApplicationID}_is1 key into the Windows registry. When the application is uninstalled, this key is removed. So we just have to check the presence of this key in the registry to know if the application has already been installed.
And i add in the
section of ISS script this :
[Code]
function InitializeSetup(): Boolean;
var
ResultCode: Integer;
ResultStr:string;
begin
// Check if the application is already install
// MsgBox('ApplicationID = ' + '{#ApplicationID}', mbInformation, mb_Ok);
begin
If RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#ApplicationID}_is1', 'UninstallString', ResultStr) then begin
If ResultStr<>'' then begin
ResultStr:=RemoveQuotes(ResultStr);
if MsgBox('{#ApplicationName} ' + ExpandConstant('{cm:CheckInstall}') + #13#13 + ExpandConstant('{cm:CheckInstallAction}'), mbConfirmation, MB_YESNO) = idYes then
if not Exec(ResultStr, '/silent', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
MsgBox('Erreur !!! ' #13#13 '' + SysErrorMessage(ResultCode) + '.', mbError, MB_OK);
end;
end;
end ;
Result := True;
end;
(...)
(extract from : https://github.com/v20100v/autoit-gui-skeleton/blob/master/source/deployment/deployment_autoit_application.iss)
++