简体   繁体   English

InnoSetup,在运行时更改Uninstallable属性的行为?

[英]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). 这意味着对用户执行隐藏安装(隐藏的目录和文件,然后将其卸载为安装程序),或者对用户执行可见的安装(常规目录和文件且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. 我默认设置为Uninstallable=True ,但是如果用户选择hidden任务,那么我想避免创建卸载程序。

How I could do it properly? 我该怎么做呢?

You can use the code shown in the Uninstallable directive documentation: 您可以使用Uninstallable指令文档中显示的代码:

[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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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