1

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. 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.

<!-- 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'/>
ChipNugget
  • 353
  • 1
  • 6
  • 14

1 Answers1

3

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.

"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):

  • 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). 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. This can also be used "large scale" to fix a broken MSI's uninstall sequence which can then be invoked on all machines. 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.

  • 3) Transform: Hack apply a transform that is then applied during uninstall (not recommended - too involved for comfort, error prone).

  • 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.

    • Works if you got a handful of machines (say 1-5 machines to clean up).
    • 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.
  • 5) Lunacy: Some use tools from "stranger shores" - such as AutoIt which simulates keystrokes to dismiss stuck dialogs. 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. You can add such a condition to the MSI using approaches 1-3 above. (NOT UILevel = 2 can be tried. Level 2 is completely silent running)


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):

Adding Condition:

Quick mock-up for how to add a conditioned custom action to the 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. 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". Didn't test that, leaving in what is there.

Here is a similar, previous answer: Suppress custom actions on uninstall.


Some Similar or Related Answer:

Stein Åsmul
  • 37,754
  • 24
  • 87
  • 158
  • The current condition for the installsequence is this: REMOVE OR UPGRADINGPRODUCTCODE – ChipNugget Dec 20 '18 at 23:28
  • I've read that I should change the condition to REMOVE="ALL". – ChipNugget Dec 20 '18 at 23:30
  • Is this a setup you are making or one you try to get rid of? How many instances to clean up? – Stein Åsmul Dec 20 '18 at 23:31
  • It's a setup for a project I am attempting to automate through Jenkins (an automated build server). The process goes like this: checkout code -> set up environment -> build project/run unit tests -> install application -> run functional tests -> uninstall application. Currently, I am unable to automate the uninstallation of the application through Jenkins because it gets stuck on the custom dialog. The wix installer is currently not utilizing UILevels. I think using UILevels is the right solution but is it as simple as setting the UILevel value in the CustomAction property?Thanks for the help! – ChipNugget Dec 20 '18 at 23:38
  • In principle setting the `UILevel condition` would work, but I don't like this approach of GUI from `InstallExecuteSequence` at all. Does this custom action need elevated rights? Is the functionality really required? (bug potential for cleanup / delete custom actions is frightening). – Stein Åsmul Dec 20 '18 at 23:40
  • My team lead suggested I create a custom flag argument rather than doing the silent ui. So if the argument is used, the dialog form will get the value of "yes." How feasible is this approach? – ChipNugget Dec 21 '18 at 00:25
  • You can use a PUBLIC (uppercase property) that is set from the command line that would suppress the display of the dialog. **`NOT PROPERTY`** as condition. You can default this to be set if the GUI is shown (InstallUISequence is then run, so you set the property there - this sequence is skipped entirely when running in silent mode). Where are the files you want to clean up located on disk? There are other ways to remove files that are built-into WiX and MSI - much better. – Stein Åsmul Dec 21 '18 at 00:32
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/185580/discussion-between-stein-asmul-and-steven). – Stein Åsmul Dec 21 '18 at 00:40
  • Sorry I was on break! I've read about using public properties from the command line. Instead of suppressing the display of the dialog, I'm thinking of setting the public property variable "FLAG" to "remove" from the command line. In the customaction method, an if statement would check if the user selected the yes button OR "FLAG" equals "remove", then the uninstaller would proceed. – ChipNugget Dec 31 '18 at 18:25
  • Is this the correct way to code this implementation? – ChipNugget Dec 31 '18 at 18:27
  • Added a quick sample to the answer. Please check. Also make sure to test properly since this was done very quickly. – Stein Åsmul Dec 31 '18 at 19:25
  • From looking at your mockup, the sequence would be executed only if it's not already installed and the flag is 1? I can see how that would bypass the custom dialogbox but I realized I can't just ignore the dialogbox. The CustomAction method actually deletes some directories so if this sequence is ignored, the product would not be a clean uninstall. – ChipNugget Dec 31 '18 at 20:06
  • I think passing the correct FLAG value in the command line and checking for that "remove" flag in the CustomAction method is sufficient. https://stackoverflow.com/questions/53990684/wix-multiple-values-in-customaction-and-public-property-in-command-line But I am currently having problems with passing the FLAG value from the command line... – ChipNugget Dec 31 '18 at 20:08
  • Added this: https://github.com/glytzhkof/SuppressUninstallErrors – Stein Åsmul Dec 07 '19 at 21:48
  • If you use the MS tool, backup first and do not cancel your long-running uninstallation. Do not forget the fact that a backup without verifying that can be restored is not a backup. – keithyip Jan 09 '20 at 04:20