简体   繁体   中英

Inno Setup Scripted Constants in uninstaller

In my Inno Setup I call a second optional Installer. Which I would like to uninstall, if my app is uninstalled. But I have to get the uninstall path of a registry key, if I don't want to guess or ask a user.

Is it possible to get this registry key while uninstalling my app as a scripted variable for "Uninstall Run"? As far as I understand "Uninstall Run" is part of unins000.dat which is fully generated on setup, so no way there?

To use the [UninstallRun] section, you have to know the path on the install time. As the constants in all sections are resolved on the install time.

If you do not know the path on install time, you have to use Pascal Script event function CurUninstallStepChanged . In the function, you can resolve the paths using Reg* support functions. Probably using RegQueryStringValue . Then you can execute the found binary using the Exec function .

[Code]

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
  Path: string;
begin
  if CurUninstallStep = usUninstall then
  begin
    if RegQueryStringValue(..., ..., ..., Path) then
    begin
      Log(Format('Executing %s...', [Path]));
      Exec(Path, ...);
    end;
  end;
end;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM