2
votes

I am working on a Wix project that need to ask users if they want to drop the database when uninstalling. I added the dialog and control in UI for the Wix project. When I click on the MSI the customized dialog for uninstall shows up but it doesn't when I click on it through Uninstall from Programs and Features.

What I need to do to have the same customized uninstall dialog show up from the Programs and Features Uninstall?

2

2 Answers

3
votes

Alternatively, there is a nice feature you can use through a custom action that tells the session to display a variety of dialog types:

Record record = new Record();
record.FormatString = string.Format("Would you like to remove program-generated data?");

MessageResult value = session.Message(InstallMessage.User | (InstallMessage)MessageBoxButtons.YesNo, record);

if (value == MessageResult.Yes)
{
     // Remove program-generated data
}

See here for where I came up with this solution: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/UI-on-uninstall-td7593560.html#a7593572

See here for the variety of dialogs you can provide: https://msdn.microsoft.com/en-us/library/windows/desktop/aa371672(v=vs.85).aspx

To use this custom action only on uninstall, schedule it like so:

<CustomAction Id="ShowDialog" BinaryKey='CustomActionsBinary' DllEntry='ShowDialogRemoveFiles' 
              Execute='immediate' Return='check' Impersonate='no'/>

<Binary Id='CustomActionsBinary' SourceFile='CustomActions.CA.dll'/>

<InstallExecuteSequence>
  <Custom Action='ShowDialog' Before='InstallFinalize'>REMOVE</Custom>
</InstallExecuteSequence>
2
votes

The Uninstall button doesn't show a MSI's UI. So your only option to control the uninstallation UI is to suppress the Uninstall button by setting ARPNOREMOVE, and thus require the user to launch maintenance.