简体   繁体   English

如果取消安装,则删除InstallShield先决条件

[英]Remove InstallShield prerequisites if installation cancelled

We use InstallShield 2010 to install our software using the InstallScript approach. 我们使用InstallShield 2010通过InstallScript方法安装软件。 There are some prerequisites that may be installed as necessary. 可能需要安装一些先决条件。 In the OnBegin callback, we execute some logic to validate the system before continuing with the installation. OnBegin回调中,我们在继续安装之前执行一些逻辑以验证系统。 If the user cancels the installer at this point, the installation will exit, but the prerequisites are not uninstalled. 如果用户此时取消安装程序,则安装将退出,但前提条件未卸载。 I have a few questions. 我有几个问题。

1) Is it possible to perform our custom validation before the prerequisites are ever installed? 1)是否可以在安装必备组件之前执行我们的自定义验证? This doesn't appear possible within InstallShield 2010 based on everything I've read, but I'd like to have that confirmed. 根据我已阅读的所有内容,这在InstallShield 2010中似乎不可能实现,但我想确认一下。

2) Is there a way to force the prerequisites to be uninstalled if the user cancels the installation? 2)如果用户取消安装,是否有办法强制先决条件被卸载?

3) Are there alternatives that would allow the prerequisites to be installed after the OnBegin callback? 3)是否有其他方法可以允许在OnBegin回调之后安装必备OnBegin I read something about prerequisites being tied to a particular feature, but it is unclear how to do this in the UI. 我阅读了一些与特定功能绑定的先决条件的信息,但尚不清楚如何在UI中执行此操作。

1) The answer to your first question is also probably the easiest most plausible solution. 1)第一个问题的答案可能也是最简单,最合理的解决方案。 You should be able to get your custom validation to run before the other prerequisites by creating your own prq file with all the custom validation logic wrapped up into it. 通过创建包含所有自定义验证逻辑的自己的prq文件,您应该能够使自定义验证在其他先决条件之前运行。 To create your own .prq file you can just copy an existing prq in the SetupPrerequisites folder and rename it. 要创建自己的.prq文件,您只需将现有的prq复制到SetupPrerequisites文件夹中,然后重命名即可。 Then open the Redistributable view in InstallShield. 然后在InstallShield中打开Redistributable视图。 The copied/renamed .prq file should now show up in the list, and you can right click and select Edit Prerequisite . 复制/重命名的.prq文件现在应显示在列表中,您可以右键单击并选择Edit Prerequisite Then change the Properties , Conditions , Files To Include , Application To Run , etc. 然后更改PropertiesConditionsFiles To IncludeApplication To Run等。

For example, suppose your validation is an executable that runs and sets a registry key depending on success. 例如,假设您的验证是一个可执行文件,可根据成功运行并设置注册表项。 You could check if the registry key exists as a condition of whether to run the prerequisite, include the exe and any dependencies in the Files to Include tab, run that executable in the Application to Run tab, and in the Behavior tab set the drop down of what happens if the launch conditions are still not met to Abort the setup 您可以检查是否存在注册表项,作为是否运行先决条件的条件,是否在Files to IncludeFiles to Include选项卡Files to Include exe和所有依赖项,在Files to Include运行的Application to Run选项卡中运行该可执行文件,然后在“行为”选项卡中设置下拉列表如果仍然不符合启动条件以Abort the setup会发生什么

After you're satisfied with all your prerequisite settings, right click again and select Set prerequisite order... and make sure that your custom validation prerequisite is at the top of the list. 对所有必备条件设置感到满意之后,再次右键单击并选择“ Set prerequisite order... ,并确保自定义验证必备条件位于列表的顶部。

2) Yes, there is probably a way to run some custom actions that will ensure all your prerequisites get uninstalled on a rollback, but that seems complicated and I personally wouldn't recommend it. 2)是的,可能有一种方法可以运行一些自定义操作,这些操作将确保在回滚时卸载所有先决条件,但这似乎很复杂,我个人不建议这样做。 What if the user already had the prerequisite installed on their machine and then they aborted your install and it uninstalled software they already had on their machine? 如果用户已经在计算机上安装了必备软件,然后中止了安装并卸载了计算机上已经安装的软件,该怎么办? They may not be too happy about that. 他们可能对此不太满意。

3) Not totally sure about this, but I don't think it's possible to have the OnBegin function execute before the prerequisites run. 3)对此不完全确定,但是我认为在先决条件运行之前OnBegin执行OnBegin函数。 I say that because normally the prerequisites are launched outside of the MSI execution by a Setup.exe or something similar, at least from my understanding. 我之所以这样说,是因为通常至少在我的理解下,这些先决条件是由Setup.exe或类似程序在MSI执行之外启动的。 Then the MSI is launched after the prerequisites complete. 然后,先决条件完成后将启动MSI。 If the OnBegin runs as part of the MSI execution (which I believe it does) then it can't be launched before the prerequisites are launched. 如果OnBegin作为MSI执行的一部分运行(我相信是这样),则在启动先决条件之前无法启动它。

Suite and Suite/Advanced UI projects available in newer versions of InstallShield handle this more directly, but how about putting OnBegin before OnBegin by wrapping one InstallScript installation in another? 较新版本的InstallShield中可用的Suite和Suite / Advanced UI项目可以更直接地处理此问题,但是如何通过将一个InstallScript安装包装到另一个安装OnBegin来将OnBegin放在OnBegin之前呢?

Regarding your other sub-questions... 关于您的其他子问题...

Prerequisites are handled in a fire and forget manner, and are designed to install things that may have already been present (and skip the installation in that case), so there's no direct support for uninstalling them. 先决条件以一种“一劳永逸”的方式处理,并且被设计为安装可能已经存在的东西(在这种情况下,跳过安装),因此不直接支持卸载它们。

Feature prerequisites are available in Basic MSI projects. 基本MSI项目中提供了功能前提条件。 For InstallScript projects, you are encouraged to use script code including LaunchApplication or similar approaches, however this can end up requiring reimplementing a prerequisite-style architecture if you don't just launch another InstallScript installation. 对于InstallScript项目,建议您使用包括LaunchApplication或类似方法的脚本代码,但是如果您不只是启动另一个InstallScript安装,那么最终可能需要重新实现先决条件样式的体系结构。

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

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