Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wix: How to warn user instead of terminating installation using Properties?

Tags:

warnings

wix

I'm searching for registry keys for Microsoft Access Database Engine on x64 machine. Here is my code:

  <Property Id="MS_ADE_X64">
    <RegistrySearch Id="MSADEX64_DIR" Root="HKLM" Key="SOFTWARE\Microsoft\Office\14.0\Access Connectivity Engine\InstallRoot"  Name="Path"  Type="directory" Win64="yes" >
      <DirectorySearch Id="MSADE_DIR" Path="[MSADEX64_DIR]" >
        <FileSearch Id ="ACECORE_DLL" Name ="ACECORE.DLL" />
      </DirectorySearch>
    </RegistrySearch>
  </Property>
  <Condition Message="This application requires Microsoft Access Database Engine (X64). Please install the Microsoft Access Database Engine (X64) then run this installer again.">
    <![CDATA[Installed OR MS_ADE_X64]]>
  </Condition>

Now here, user is presented with a message and installation will quit.

Question: How would I prevent the Termination of installation and present the user with h a warning message instead, and installation would continue?

Thanks and best regards.

like image 220
Farrukh Waheed Avatar asked Jul 11 '11 15:07

Farrukh Waheed


2 Answers

The best way I've found to do it is to create a custom dialog box with the warning message. I like to use WixEdit to tweak a pre-existing dialog.

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>

    <!-- QuickTime is not installed warning dialog -->
    <UI>
      <Dialog Id="QtWarningDlg" Width="284" Height="73" Title="QuickTime Note" NoMinimize="yes">
        <Control Id="Text" Type="Text" X="38" Y="8" Width="240" Height="40" TabSkip="no">
          <Text>QuickTime version 7.5.5 or higher is required for some components to function correctly. You may proceed with installation, but be sure to install QuickTime if you will be using any of those components.</Text>
        </Control>
        <Control Id="OK" Type="PushButton" X="114" Y="52" Width="56" Height="17" Default="yes"  Cancel="yes" Text="OK">
          <Publish Event="EndDialog" Value="Return">1</Publish>
        </Control>
      </Dialog>
    </UI>

    </Fragment>
</Wix>

Then we schedule it based on a condition

<InstallUISequence>
  <Custom Action="GetQuickTimeVersion" Before="QtWarningDlg"/>

  <!-- Warn if QuickTime is not installed -->
  <Show Dialog="QtWarningDlg" After="AppSearch">
    <![CDATA[NOT Installed AND ((QUICKTIME_VERSION = "") OR (QUICKTIME_VERSION < "#123043840"))]]>
  </Show>
</InstallUISequence>
like image 161
Dave Andersen Avatar answered Sep 23 '22 15:09

Dave Andersen


I also tried but it was not working for Java Runtime.

Assigning registry search result to property.

<Property Id="JAVACURRENTVERSION">
        <RegistrySearch Id="JRE_KEY" Root="HKLM" Key="SOFTWARE\JavaSoft\Java Runtime        Environment" Name="CurrentVersion" Type="raw"  />
    </Property>

And then using this property to conditionally show warning dialog,

<UI>
        <Dialog Id="JavaWarningDlg" Width="284" Height="73" Title="Java Runtime" NoMinimize="yes">
            <Control Id="Text" Type="Text" X="38" Y="8" Width="240" Height="40" TabSkip="no">
              <Text>JRE version 1.6 or higher is required for some components to function correctly. You may proceed with installation, but be sure to install JRE if you will be using any of those components.</Text>
            </Control>
            <Control Id="OK" Type="PushButton" X="114" Y="52" Width="56" Height="17" Default="yes"  Cancel="yes" Text="OK">
              <Publish Event="EndDialog" Value="Return">1</Publish>
            </Control>
        </Dialog>
    <InstallUISequence>
        <!-- Warn if Java is not installed -->
      <Show Dialog="JavaWarningDlg" Before="ResumeDlg">       
        <![CDATA[NOT Installed AND JAVACURRENTVERSION < "1.6"]]>
      </Show>
    </InstallUISequence>
</UI>

It was not working in all cases so, I investigate it with detailed log and found that "PrepareDlg" called earlier than property assigining so I switched the case Before="PrepareDlg" to Before="ResumeDlg".

Now it is working fine.

like image 35
Yawar Avatar answered Sep 24 '22 15:09

Yawar