简体   繁体   中英

InnoSetup, change the Uninstallable property behavior at runtime?

SCENARIO

I have created an installer that will installs a Malware application for educative purposes, the installer contains these two tasks:

[Tasks]
Name: hidden; Description: Hidden mode; GroupDescription: Installation Mode
Name: visible; Description: Visible mode; GroupDescription: Installation Mode

This means, performs a hidden installation for the user (hidden dirs and files and make uninstallabe the installer), or a visible installation (normal dirs and files and Uninstallable=True).

PROBLEM

I've set the Uninstallable=True by default, but If the user selects the hidden task then I would like to avoid the uninstaller creation.

How I could do it properly?

You can use the code shown in the Uninstallable directive documentation:

[Setup]
...
Uninstallable=not IsTaskSelected('hidden')

[Tasks]
Name: hidden; Description: Hidden mode; GroupDescription: Installation Mode
Name: visible; Description: Visible mode; GroupDescription: Installation Mode

Optionally, if you'd need more complex statements written in reusable function, or access some of the scripting code elements, you could write a function, eg:

[Setup]
...
Uninstallable=IsUninstallable

[Tasks]
Name: hidden; Description: Hidden mode; GroupDescription: Installation Mode
Name: visible; Description: Visible mode; GroupDescription: Installation Mode

[Code]
function IsUninstallable: Boolean;
begin
  Result := WizardSilent or not IsTaskSelected('hidden');
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