- 如何仅记录Installshield 2008制作的MSI文件所做的更改,以便通过“自我修复”重新安装?
- 什么是自我修复背后的原因?
- 如何使用Installshield 2008禁用MSI的自我修复功能?
自修,简单易懂的解释: 如果我删除一个文件,为什么MSI安装程序会重新配置?
更新:现在有一种更短、更注重解决方案的答案可用,建议先尝试这个答案。这个答案侧重于"理解自我修复",而不是解释如何消除问题。您可能也想阅读本回答的第一部分。
这篇“文章”已经变得很大且有些难以阅读。这里是一个新写的前言-用于修复意外自我修复的简短"解决版本"(通常在VB6、Visual Studio、MS Office、MS Outlook、AutoCAD等中发现)。
本文的其余部分详细描述了自我修复问题。自我修复的潜在原因远不止本“简短”章节所述。
Windows Installer是一种部署技术,其工作是安装指定的文件和注册表设置,并将它们保留在指定的安装位置,并确保它们是正确的版本 - 自我修复或弹性是实现这一目标的机制。它的操作与开发人员需要即时交换文件以进行调试、开发和测试的需求相冲突。
因此,许多自我修复(弹性)仅仅是由于开发人员尝试调试他们安装的应用程序并即时交换文件而触发。请参见下面的“一些典型的自我修复问题场景”中的第2节,了解如何处理这种情况。在其他情况下,存在MSI中的真正设计错误必须进行更正,或者会导致自我修复的系统管理陷阱 - 有时错误源可能很难找到。
我曾在serverfault.com上就自修问题发表过文章。那篇文章是针对系统管理员撰写的,现在看来可能比这篇(针对开发人员的)更易于理解。在stackoverflow上还有另一个更短的答案:为什么删除文件后MSI安装程序需要重新配置?(这可能是最简短且最容易理解的)。最后,我找到了一篇非常好的关于自修的文章,作者是Vadim Rapp:如何解决Windows Installer尝试自修的问题。这篇文章值得一读。下面的部分"一些典型的自我修复问题场景"中详细介绍了详情,但是作为一个快速预示列表 - 主要原因包括:
1. 公司MSI文件打包不良或来自供应商的MSI设计缺陷(MSI软件包本身设计不良,由于各种原因意外触发自我修复)
2. 外部原因干扰导致文件或注册表键被删除,包括(登录)脚本、标准操作系统功能、病毒、安全软件等...
3. Windows设计更改、缺陷或限制导致有缺陷或问题的部署
Windows Installer旨在安装您的应用程序二进制文件、设置和数据文件,并保持它们已安装并确保它们是正确的版本。自我修复是实现这一目标的机制。总体概念称为弹性 - 即在启动应用程序之前,损坏的安装将触发自我修复。
弹性或自我修复是Windows Installer的一个内置主要概念,不能以任何安全方式关闭。有时人们会做最难以置信的事情,例如禁用整个Windows Installer引擎来停止自我修复。这显然绝不能做。必须确定修复的原因,并解决问题,而不是创建新问题或黑客攻击系统。
每次启动广告快捷方式(本质上是指向Windows Installer功能而不是直接指向文件的特殊快捷方式),Windows Installer都会通过检查产品的"组件关键路径"来验证安装。如果发现差异,则会触发修复以纠正不完整的安装。"组件关键路径"是指在MSI内部为组件指定的"关键文件" - 每个组件都有一个。自我修复也可以通过实例化COM服务器(或尝试实例化)的人、通过其文件扩展名或MIME注册激活文件的人以及其他几种方式来启动。以下是Symantec关于"自我修复入口点"的全面文章: 使用入口点启动自我修复和广告功能。如果文件被删除、移动或简单地被覆盖(由用户手动或以某种自动方式),则可能会导致自我修复(如果文件或注册表设置未设置为关键路径,则不会触发自我修复)。
自我修复的触发器通常可以在自我修复发生的系统的事件查看器中找到。按照以下步骤打开事件查看器:
或者可以执行以下操作:开始 => 运行... => eventvwr.exe,只查看事件查看器。如果在开始菜单中没有看到"运行",请按WIN键 + R。
MSI专家和MVP Stefan Krüger有一篇关于同样自我修复问题的文章。他重要地讨论了实际事件日志条目及其含义。请在那里阅读有关实际调试过程的内容。
这是对上面概述中已经概述的几种自修问题场景的“冗长解释”。
Many self-repair problems are actually caused by developers trying to debug their applications by replacing files on the fly, deleting files or renaming them. Or they may use cleanup registry scripts and / or batch scripts to unregister and register COM files, COM-Interop, GAC files, file associations, or other common developer debug and development tasks.
This hot-swapping can triggering self-repair when the application is launched via an advertised shortcut.
A top tip for developers struggling with self-repair during application debugging is to not launch the application from an advertised shortcut, but to launch the main EXE directly from Windows Explorer or from a manually created shortcut. This will bypass the most common "self-repair entry point" - the advertised shortcut. Self-repair may still result from broken COM data, advertised file associations and a few other special cases (read this Symantec article for entry point information).
Other applications or rather other MSI packages can break your installation and cause self-repair by interfering with registry data - typically COM settings, but also with other settings and files. These can be some of the hardest cases to solve, since the applications are basically fighting it out and the last one to run will update the registry each time. Typically both MSI files must be redesigned for the applications to operate on the same machine. Or, as is the order of the day, the whole application may be virtualized (for example: Microsoft App-V virtual packages) and run in its own sandbox which seems to be what is done more and more in companies these days. This error scenario is often seen with a suite of badly repackaged applications in a corporate environment. COM fragments from different packages overwrite the COM server's disk path from another package, and self-repair fighting ensues on each application launch via an advertised shortcut. The same file name with different file versions can also be registered from different file locations and share some registry settings that interfere. As far as I recall at least 7 variables or settings in the file system and registry must be in sync for a COM server to be properly instantiable. See section 7 below for a more specialized description of COM interference in the context of VB6 and VBA COM applications.
A component key path is pointing to a temporary file that has been deleted by the application or it will be deleted by the system eventually via some sort of cleanup mechanism (can also be a cleanup tool such as ccleaner). This is common for files in the temp folder itself. This is solved by not installing the temp file, or putting the file somewhere else and making it permanent. I have seen this error most often in the world of corporate application repackaging where a faulty cleanup of the captured image leads to the install of a temporary file that should not have been included in the package at all. Often they may be temporary files waiting for a reboot to be installed to their intended, perhaps protected location, and the reboot was never performed - a common application packaging error. To a lesser degree I have seen it in auto-generated packages coming out of automated build systems.
Permission problems: if a key file for a component is installed to a location that is not accessible for the user who invokes the application. Windows Installer might not "see" the installed file / key path, or be unable to add the file to the folder. These issues can be more exotic to debug, and may not happen that often. There are several variations on this issue:
Another class of self-repair problems emerges in relation to terminal servers and Citrix. The whole windows installer service could be locked down so any self-repair invoked to add per user data could fail and consequently self-repair may fail or more likely not run at all. This is reason enough to not rely on self-repair as a way to add user data like some MSI files do, and such constructs must be replaced with application deployment of user files copied from per-machine locations or the less effective ActiveSetup feature from Microsoft that runs once per user.
VB6 applications and VBA applications, which are heavily COM based with massive potential for COM interference (COM settings overwriting each other and becoming inconsistent), have been known to trigger several mysterious self-repair problems, most of which have not been properly explained. This can also happen on launch of Visual Basic 6 (VB6) or Visual Studio (and many other applications). The common denominator is that some error in the current installation state triggered the self-repair, and you can track down the culprit product and component by following the steps outlined in the section above called "Finding the trigger or culprit for the self-repair". Be sure to report your findings here (I never use VB6 or VBA anymore - your detailed findings could help others with a long-standing annoyance).
A special case of Windows Installer repair or self-repair that is worth mentioning for completeness, was the issue with Microsoft Office several years ago where a self-repair would be triggered, and you would be asked to insert the Microsoft Office installation media (in those days CD-ROMs or DVDs - today maybe thumb drives). As far as I recall this was related to an erroneous call to the built in Windows Installer standard action "ResolveSource" which unexpectedly (and unnecessarily) triggered the prompt for the installation media. A very common support call back in the day and mentioned here for completeness. It is important to note that this problem can still occur whenever MS Office is installed from any removable media (rather than the better option of a network share). This happens when MS Office detects that it needs to install further, optional (and usually shared) components of the product that were not installed originally. For example unusual spell-checkers, various templates or specific and rarely used tools. It is possible to install these components to "install on first use" (advertised features is the proper Windows Installer term).
There are many other possible scenarios. To mention a few:
最后,存在一些 自我修复的良性用途,它们只会发生一次,不构成错误。这是 自我修复的合法和正确使用方式,尽管可能与设计错误一样令人烦恼,并且在用户干预下可能会反复出现: