I know how to overwrite the files using this method
[Files]
Source: \"Project\\*\"; DestDir: \"{app}\"; Flags: ignoreversion recursesubdirs onlyifdoesntexi
First, your code seems wrong. With the onlyifdoesntexist
flag, the files are never overwritten, contrary to what you claim.
Anyway, a solution is to create two [Files]
entries, one that overwrites and one that does not. And use the Pascal scripting to pick the entry for a respective installation mode.
[Files]
Source: "Project\*"; DestDir: "{app}"; Flags: ... onlyifdoesntexist; ...; Check: IsUpgrade
Source: "Project\*"; DestDir: "{app}"; Flags: ...; ...; Check: not IsUpgrade
Example of IsUpgrade
implementation:
[Code]
function IsUpgrade: Boolean;
var
S: string;
InnoSetupReg: string;
AppPathName: string;
begin
{ The ExpandConstant is here for Inno Script Studio, }
{ which generated AppId in a form of GUID. }
{ The leading { of the GUID has to be doubled in Inno Setup, }
{ and the ExpandConstant collapses that back to single {. }
InnoSetupReg :=
ExpandConstant(
'Software\Microsoft\Windows\CurrentVersion\Uninstall\{#SetupSetting("AppId")}_is1');
AppPathName := 'Inno Setup: App Path';
Result :=
RegQueryStringValue(HKLM, InnoSetupReg, AppPathName, S) or
RegQueryStringValue(HKCU, InnoSetupReg, AppPathName, S);
end;
See also Pascal scripting: Check parameters.