How do I Display a Custom Error Message in Bundle

132 Views Asked by At

I am working on a bootstrapper project that when run, installs a 32bit or 64bit driver depending on the architecture the installed program is.

I would like to display an error message, prevent installation and close the application if there is no 32bit or 64bit program installed on the machine.

This is what I have but the <Condition> is causing an invalid child element error. Perhaps I cannot use a condition in the chain but is there a way I could do this very simply or will I need to create an <ExePackage>?

<Bundle...      
    <!-- Define variables -->
    <Variable Name="ErrorMessage" Type="string" Value="Neither the 32-bit nor the 64-bit program is installed." />
      
    <!-- Registry searches -->      
    ...
    <Chain>

        <MsiPackages...    
    
         <Condition Message="[ErrorMessage]">
          <![CDATA[NOT ProgramInstalled32 AND NOT ProgramInstalled64]]>
        </Condition>
    
    </Chain>
</Bundle>
1

There are 1 best solutions below

0
Leanne On

I got it working! After some research on the Condition tag and how it works I realized the approach I had was wrong because the MsiPackage will not install if the Condition returns false.

This is my solution, I put it just under the chain:

  <bal:Condition Message="The Product is not installed.">
        (ProgramInstalled32 = 1) OR (ProgramInstalled64 = 1)
  </bal:Condition>

I tested it and when I ran the .EXE it installed the 64bit driver as I have the 64bit program installed. And when I uninstalled the program, then ran the .EXE, the error message displayed and prevented the installation. Hope this works for you!