简体   繁体   English

wix - 静默卸载应用程序的自定义操作对话框

[英]wix - custom action dialogbox on silent uninstall of application

I am attempting to silently uninstall a windows application with the flags: /quiet and /uninstall but the installer currently does not suppress a CustomAction dialog box.我正在尝试以静默方式卸载带有以下标志的 Windows 应用程序:/quiet 和 /uninstall,但安装程序当前不会抑制 CustomAction 对话框。 When the dialog box appears, the user needs to confirm (by pressing the yes button) to remove all program-generated data.当对话框出现时,用户需要确认(通过按是按钮)以删除所有程序生成的数据。

Is there a way to tell the uninstaller to click "yes" on quiet mode?有没有办法告诉卸载程序在安静模式下单击“是”?

Below is the current wix code.以下是当前的 wix 代码。

<!-- Remove app data custom action -->
<CustomAction Id="SetPathToRemove" Property="ShowRemoveFilesDialog" Value="[ApplicationAppDataDir]" />
<CustomAction Id="ShowRemoveFilesDialog" BinaryKey='CustomActionsBinary' DllEntry='ShowDialogRemoveFiles'
              Execute='deferred' Return='ignore' Impersonate='no'/>

Cross-Link : Similar answer and short version .交叉链接类似的答案简短版本 And the older: I screwed up, how can I uninstall my program?和老人: 我搞砸了,我怎么能卸载我的程序?


Suppress Dialog : If that dialog is shown without a proper condition then no, you can not suppress it outright, but there are many workarounds.抑制对话框:如果该对话框在没有适当条件的情况下显示,那么不,您不能完全抑制它,但有很多解决方法。 See list of "fixes" below.请参阅下面的“修复”列表。

Stuck Uninstalls : First some comments on stuck uninstalls (hanging / stuck or rolling back).卡住卸载:首先对卡住卸载(挂起/卡住或回滚)进行一些评论。 There are several ways you can get stuck and here are just a few:有几种方法可以让你卡住,这里只是一些:

  • Faulty Conditions : Faulty conditions can show dialogs erroneously or run custom actions during uninstall that should not run.错误条件:错误条件可能会错误地显示对话框或在卸载期间运行不应运行的自定义操作。 Respectively this typically means stuck uninstall (dialog) or an uninstall that fails and rolls back (CAs).这通常意味着卸载卡住(对话框)或卸载失败并回滚(CA)。 A dialog gets you stuck when running silently and it will also halt an interactive major upgrade (you must dismiss the dialog manually or the major upgrade will sit there waiting).一个对话框在静默运行时会让您卡住,它还会停止交互式主要升级(您必须手动关闭对话框,否则主要升级将坐在那里等待)。 To make matters worse the dialog can show up underneath other desktop windows.更糟糕的是,对话框可能会显示在其他桌面窗口下方。
  • Other Catch 22s : A few other causes of failed uninstalls are possible.其他 Catch 22 :可能有其他一些导致卸载失败的原因。
    • The prior uninstall of a shared runtime required by your own custom actions is one.您自己的自定义操作所需的共享运行时的事先卸载就是其中之一。 This could be a version of the .NET framework, the VC Runtime, or anything you depend on that is already gone by the time you invoke your own uninstall.这可能是 .NET 框架的一个版本、VC 运行时或您所依赖的任何东西,在您调用自己的卸载时已经消失了。 The CAs fall over and the setup rolls back. CA 倒下,设置回滚。
    • I have also seen Launch Conditions act up and prevent setup launch if they check for the presence of a missing prerequisite!如果他们检查是否存在缺少的先决条件,我还看到启动条件会起作用并阻止设置启动! Essential catch 22!关键抓22! For example: the .NET framework 2.0 is missing - which your app needs, but the uninstall does not - and this causes the setup to fail to uninstall as Launch Conditions are not met.例如:缺少 .NET framework 2.0 - 您的应用需要,但卸载不需要 - 这会导致安装程序无法卸载,因为启动条件不满足。 Who decided to make launch conditions work like this on uninstall too?谁决定在卸载时也让启动条件像这样工作? The WiX guys to the rescue with the (OR Installed) trick (this causes launch conditions to always be true when the setup is already installed). WiX 家伙使用(OR Installed)技巧进行救援(这会导致启动条件在已安装设置时始终为真)。

"Fixes" : There are some "fixes" of varying degrees of "insanity" for failing or stuck uninstalls (generally for the failing ones where custom actions cause the uninstall to roll-back and fail to complete - a catch 22 situation where you can't go forwards or backwards). “修复” :对于失败或卡住的卸载,有一些“疯狂”程度不同的“修复”(通常是针对自定义操作导致卸载回滚并无法完成的失败的那些 - 一个 catch 22 情况,您可以不要前进或后退)。

  • 1) MS FixIt : There is a Microsoft FixIt tool that sometimes allows you to get rid of stuck installs (not sure if it applies to dialogs from custom actions). 1) MS FixIt :有一个Microsoft FixIt 工具,有时可以让您摆脱卡住的安装(不确定它是否适用于自定义操作的对话框)。 Try this first if you have one or just a few instances.如果您有一个或只有几个实例,请先尝试此操作。
  • 2) Minor Upgrade / Patch : Patch the existing installation with a minor upgrade (preferred approach) - Chris Painter's answer . 2)小升级/补丁Patch the existing installation with a minor upgrade - Chris Painter 的回答 This can also be used "large scale" to fix a broken MSI's uninstall sequence which can then be invoked on all machines.这也可以“大规模”用于修复损坏的 MSI 卸载序列,然后可以在所有机器上调用该序列。 The real fix if you like (once the problem is there on a large scale with many machines affected).如果您愿意,真正的解决方案(一旦问题大规模出现,许多机器受到影响)。 There are some challenges in logistics .物流方面存在一些挑战 Corporations with distribution systems can usually incorporate a patch as part of upgrade installations pretty easily.拥有分发系统的公司通常可以很容易地将补丁作为升级安装的一部分。 They might not be too happy about it though :-).不过,他们可能对此不太高兴:-)。

  • 3) Transform : Hack apply a transform that is then applied during uninstall (not recommended - too involved for comfort, error prone). 3)变换Hack apply a transform ,然后在卸载期间应用(不推荐 - 太复杂了,容易出错)。

  • 4) Dr.No No : If there are few instances you can hack the locally cached MSI database (basically the same that happens via a patch, only done manually). 4) Dr.No No :如果很少有实例,您可以hack the locally cached MSI database (基本上与通过补丁发生的相同,仅手动完成)。

    • Works if you got a handful of machines (say 1-5 machines to clean up).如果您有几台机器(比如要清理 1-5 台机器),则可以使用。 You can use the Orca tool from the MSI SDK.您可以使用 MSI SDK 中的 Orca 工具。
    • Support job - not without risk!支持工作 - 并非没有风险! Not recommended.不建议。
    • And don't delete custom actions! Just add a condition "AND 0" to the offending custom action sequencing - that will stop the custom action from running And don't delete custom actions! Just add a condition "AND 0" to the offending custom action sequencing - that will stop the custom action from running . And don't delete custom actions! Just add a condition "AND 0" to the offending custom action sequencing - that will stop the custom action from running
  • 5) MSI API : I rely on minor upgrade patching to fix things. 5) MSI API :我依靠小升级补丁来修复问题。 However, it should be possible to modify the installed MSI via MSI API automation to change a few things in the locally, cached MSI to allow uninstall.但是,应该可以通过 MSI API 自动化修改已安装的 MSI,以更改本地缓存 MSI 中的一些内容以允许卸载。 Essentially an automated version of the previous "hack local MSI approach".本质上是以前“破解本地 MSI 方法”的自动化版本。 Somewhat insane to try, but not impossible on paper ( beware of looking like malware and ruining your trust gained by SmartScreen ! - many vendors struggle with their product detected as false positive malware - it is horrendous to deal with and can ruin your product's reputation).尝试有点疯狂,但在纸面上并非不可能(当心看起来像恶意软件并破坏您通过SmartScreen获得的信任! -许多供应商都在为他们的产品被检测为 误报恶意软件而苦苦挣扎-处理起来很可怕,并且可能会破坏您产品的声誉) . The changes could be done via an executable included in your setup.exe and launched prior to the installation of your new MSI (the new MSI on its own run without the setup.exe will still fail).更改可以通过setup.exe中包含的可执行文件完成,并在安装新 MSI 之前启动(新 MSI 在没有setup.exe的情况下自行运行仍会失败)。 Remember that all fixes add new sources of bugs!请记住,所有修复都会添加新的错误来源! (my fix for my failed fix failed, etc...). (我对失败的修复的修复失败了,等等......)。

  • 6) Lunacy : Some use tools from "stranger shores" - such as AutoIt which simulates keystrokes to dismiss stuck dialogs. 6) Lunacy :有些人使用来自“陌生海岸”的工具——例如 AutoIt,它模拟击键以消除卡住的对话框。 Not at all good enough large-scale, but might work for smaller scenarios.根本不够大规模,但可能适用于较小的场景。 Not recommended.不建议。 Try tools like these against security software!试试这些工具来对付安全软件! Oh no!不好了! (anything can happen, it WILL break - just a matter of time). (任何事情都可能发生,它会破裂——只是时间问题)。

Conditions : You should never show a dialog from a custom action sequenced in the InstallExecuteSequence , though you can control its display using the UILevel property .条件:您不应该显示来自InstallExecuteSequence中排序的自定义操作的对话框,尽管您可以使用UILevel 属性控制其显示。 You can add such a condition to the MSI using approaches 1-3 above.您可以使用上述方法 1-3 将此类条件添加到 MSI。 ( NOT UILevel = 2 can be tried. Level 2 is completely silent running) NOT UILevel = 2可以尝试。Level 2 是完全静默运行)


Suppress Failing Custom Actions : When uninstall is prevented by failing custom actions (as opposed to rouge dialogs), you could resort to an "inoculation method".抑制失败的自定义操作:当通过失败的自定义操作(与胭脂对话框相反)阻止卸载时,您可以求助于“接种方法”。 You can update your package to be able to suppress custom actions via a command line switch which sets a specific property as a flag:您可以更新您的包,以便能够通过将特定属性设置为标志的命令行开关来抑制自定义操作:

msiexec.exe /x {PRODUCT-GUID} SUPPRESSERROR="1"

See this WiX sample , or the mockup below (slightly different, but the same concept): 请参阅此 WiX 示例或下面的模型(略有不同,但概念相同):

Adding Condition :添加条件

Quick mock-up for how to add a conditioned custom action to the InstallExecuteSequence :快速模拟如何将条件自定义操作添加到InstallExecuteSequence

<Property Id="FLAG" Value="1"/>

<..>

<CustomAction Id='Something' Property='INSTALLFOLDER'
              Value='[CMDLINE_INSTALLFOLDER]' Execute='firstSequence' />

<..>

<InstallExecuteSequence>
   <Custom Action='Something' Before='AppSearch'>NOT Installed AND FLAG</Custom>
</InstallExecuteSequence>

With this approach all custom actions can be suppressed from running by invoking this kind of customized msiexec.exe command.使用这种方法,可以通过调用这种自定义的 msiexec.exe 命令来禁止运行所有自定义操作。 Hence problematic custom action during uninstall or upgrade can be suppressed.因此,可以抑制卸载或升级期间有问题的自定义操作。 This is just an "emergency method" to get something uninstalled.这只是卸载某些东西的“紧急方法”。

I guess I should make the condition NOT Installed AND FLAG="1" .我想我应该设置条件NOT Installed AND FLAG="1" Didn't test that, leaving in what is there.没有测试,留下那里的东西。

Here is a similar, previous answer: Suppress custom actions on uninstall .这是一个类似的先前答案: Suppress custom actions on uninstall


Some Similar or Related Answer :一些类似或相关的答案

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

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