简体   繁体   English

Inno Setup - 是否可以在卸载期间根据条件卸载文件?

[英]Inno Setup - Is it possible to uninstall files based on a condition during uninstall?

To understand how I use the software:要了解我如何使用该软件:

When starting the installer, the user can choose whether to install or update the software.启动安装程序时,用户可以选择是安装还是更新软件。 If he installs the software with the install option, then the software can also be uninstalled regularly via the uninstaller.如果他使用安装选项安装软件,那么也可以通过卸载程序定期卸载该软件。

I now also misuse the installation function as an update function. Here let's distinguish between the normal upgrade function of Inno Setup and my created update option via code.我现在也误用安装function作为更新function。这里让我们区分Inno Setup的正常升级function和我通过代码创建的更新选项。 The update option is nothing more than a normal installation.更新选项无非是正常安装。 However, the user must specify any paths to the pre-installed software beforehand.但是,用户必须事先指定预装软件的任何路径。 This has to do with the fact that most of our users have already installed the software manually before.这与我们的大多数用户之前已经手动安装了该软件这一事实有关。 (Java, Tomcat and our web application). (Java,Tomcat 和我们的 web 应用程序)。 The normal installation and my specially created update option work fine so far.到目前为止,正常安装和我专门创建的更新选项工作正常。

By means of registry entries set during installation or update, I can distinguish whether the software has been installed or updated using the "Installer" or "Updater" option.通过安装或更新时设置的注册表项,我可以使用“Installer”或“Updater”选项区分软件是否已安装或更新。

If the user has now installed the software via the normal installation option, then it should be possible to uninstall it completely.如果用户现在已经通过正常安装选项安装了软件,那么应该可以完全卸载它。 This means that the (Inno Setup) Uninstaller should delete all files.这意味着 (Inno Setup) 卸载程序应该删除所有文件。 However, this should not be the case if the user uses the update option.但是,如果用户使用更新选项,则不应出现这种情况。 The update function works by backing up some files before the regular installation, deleting unnecessary files using DelTree, and then letting the installation recreate them.更新 function 的工作原理是在常规安装之前备份一些文件,使用 DelTree 删除不需要的文件,然后让安装重新创建它们。

Is it possible to set a condition so that the uninstaller does not delete these files in the "Files" section if the user has previously used the Update option?如果用户以前使用过更新选项,是否可以设置一个条件,以便卸载程序不会删除“文件”部分中的这些文件?

Normally, of course, the uninstaller should delete these files if the user has previously installed the software using the install option.当然,通常情况下,如果用户之前使用安装选项安装了软件,卸载程序应该删除这些文件。 However, I would like these files not to be deleted if the user has previously selected the update option in the installer.但是,如果用户之前在安装程序中选择了更新选项,我希望这些文件不会被删除。

The following is a brief portion of my options:以下是我的选项的一小部分:

[Setup]
UninstallFilesDir={code:UnInstallerPath}

[Files]
Source: "<source>\Tomcat9\*"; DestDir: "{code:GetTomcatSourcepath}"; Excludes: "webapps"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "<source>\{#JAVA}\*"; DestDir: "{code:GetJAVAExtractpath}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "<source>\Tomcat9\webapps\ROOT\*"; DestDir: "{code:GetWebAppSourcepath}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "<source>\config\*"; DestDir: "{code:GetConfigInstallPath}"; Check: IsInstaller; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "<source>\libraries\{#DLLFile}"; DestDir: "{code:GetConfigInstallPath}"; Flags: ignoreversion 

[UninstallDelete]
Type: filesandordirs; Name: "{code:GetUninstallPath}"; Check: IsInstalledviaProgram;
Type: filesandordirs; Name: "{code:UnInstallerPath}";

So the uninstaller should not delete any files other than its own exe and the associated data file if the installer was only used for the update using my created update function.因此,如果安装程序仅用于使用我创建的更新 function 的更新,则卸载程序不应删除除其自身的 exe 和关联数据文件以外的任何文件。

Due to the fact that I want to be able to uninstall the application if it was previously installed by the installation option, I unfortunately cannot use the "uninsneveruninstall" flag.由于我希望能够卸载以前通过安装选项安装的应用程序,因此很遗憾我无法使用“uninsneveruninstall”标志。

For better understanding, you can see in the following picture the first page that is displayed after starting the installer.为了更好地理解,您可以在下图中看到启动安装程序后显示的第一个页面。 选择页面

AllCheck functions (including those in the UninstallDelete section are evaluated on install time. Not on uninstall time.所有Check功能(包括UninstallDelete部分中的功能)均在安装时进行评估。而不是在卸载时进行评估。

Based on the name of your IsInstalledviaProgram function, I guess that it is implemented in a way to work in the uninstaller (by checking the registry entries?).根据您的IsInstalledviaProgram function 的名称,我猜它是以一种在卸载程序中工作的方式实现的(通过检查注册表项?)。 But it is actually executed during the installation.但它实际上是在安装过程中执行的。 So you should check for the radio buttons, not the registry entries (whose state at the time the function is called likely do not correspond yet).因此,您应该检查单选按钮,而不是注册表项(调用 function 时其 state 可能尚未对应)。 Maybe the IsInstaller is the function you should use.也许IsInstaller是您应该使用的 function。

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

相关问题 使用 Inno Setup 添加卸载信息 - Adding uninstall information with Inno Setup Inno Setup:无需管理员权限即可卸载 - Inno Setup: Uninstall without administrator privilege Inno Setup:如何更改卸载背景颜色 - Inno Setup: How to change uninstall background color 使用另一个(管理员)帐户卸载非管理员安装时,不会删除 Inno Setup Uninstall 条目 - Inno Setup Uninstall entry is not removed when uninstalling non-administrator installation using another (administrator) account InstallShield使用installdir属性在卸载过程中运行批处理文件 - InstallShield Running batch files during uninstall using installdir property Visual Studio卸载安装程序尝试卸载不存在的内容 - Visual studio uninstall setup trying to uninstall things that dont exsist 在 Inno Setup 中卸载期间从所有用户配置文件中删除日志文件 - Deleting log files from all user profiles during uninstallation in Inno Setup 静默重新安装期间Inno Setup程序包的行为 - Behavior of Inno Setup package during silent reinstall 卸载软件 - Uninstall software 卸载先前版本已安装的安装项目的新版本 - uninstall previous version installed new version of setup project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM