tags:

views:

2789

answers:

3

I have a Wix project that installs a few exe files. One is the 'Main' executable and the others are supporting programs to help diagnose problems.

The main executable is optional, and the support programs will run on their own. Often, the end user will install a thrid-party program instead of my main executable.

At the end of the wix installer, I want to have a 'launch program' checkbox that will run the program as soon as the installer closes.

I can hide the checkbox based on the INSTALLLEVEL property, but that only changes depending on if the user selected a 'Typical' or 'Complete' install. I would like to hide it based on if the main executable feature is installed or not.

Something like this would be ideal:

<Feature Id='MainProgram' Title='MainExe' Description='This application stores and displays information from our hardware.'
         ConfigurableDirectory='INSTALLDIR' Level='4'
         AllowAdvertise='no'>
  <ComponentRef Id='MainExecutable' />
  <ComponentRef Id='SQLLibrary' />
  <ComponentRef Id='ProgramIcon' />
  <ComponentRef Id='RemovePluginsFolder'/>
  <Property Id='ShowFinalCheckbox'>1</Property> #<--This won't work, but I'd like it to.
</Feature>
+4  A: 

The SetProperty element can be used to change the value of a Property before or after an action. To set a value based on the install state of an executable I would use a combination of Component states documented in the Conditional Statement Syntax in MSI SDK. You'll have to play around with this example, but I think this will get you close.

<SetProperty Id="ShowFinalCheckBox" Value="1" After="CostFinalize>?MainExecutableComponent&gt;2 OR $MainExecutableComponent&gt;2</SetProperty>

All of the magic in there is explained in the link to the MSI SDK above.

Rob Mensching
Took me a while to figure out that SetProperty is only on Wix3. I would have started with Wix3 if the official tutorial extended beyond the first lesson. Might be a good time to switch.
Grant
Yeah, sorry, WiX v3 feature. But it is just syntatic sugar. You can get the exact same thing in WiX v2 (or WiX v3) with a CustomAction to set a Property and then schedule it appropriately. Just more work than the WiX V3 syntax.
Rob Mensching
+1  A: 

For Wix2 you can use &Feature to find out if that feature is installed or not.

<Dialog Id="ExitDlg" Width="370" Height="270" Title="[ProductName] [Setup]" NoMinimize="yes">
    <Control Id="Finish" Type="PushButton" X="236" Y="243" Width="56" Height="17"
             Default="yes" Cancel="yes" Text="Finish">
      <Publish Event="EndDialog" Value="Return">1</Publish>
      <Publish Event="DoAction" Value="LaunchFile">(NOT Installed) AND (LAUNCHPRODUCT = 1) AND (&amp;MainExecutable = 3)</Publish> 
    </Control>
    <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Disabled="yes" Text="Cancel" />
    <Control Id="Bitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="234" TabSkip="no" Text="[DialogBitmap]" />
    <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Disabled="yes" Text="Back" />
    <Control Id="Description" Type="Text" X="135" Y="70" Width="220" Height="20" Transparent="yes" NoPrefix="yes">
      <Text>Click the Finish button to exit the Wizard.</Text>
    </Control>
    <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
    <Control Id="Title" Type="Text" X="135" Y="20" Width="220" Height="60" Transparent="yes" NoPrefix="yes">
      <Text>{\VerdanaBold13}Completing the [ProductName] Wizard</Text>
    </Control>
    <Control Id="Launch" Type="CheckBox" X="135" Y="120" Width="150" Height="17"
             Property="LAUNCHPRODUCT" CheckBoxValue="1">
      <Text>Launch [ProductName]</Text>
      <Condition Action="hide">
        NOT (&amp;MainProgramFeature = 3)
      </Condition>
    </Control>
  </Dialog>

This way, you can hide the dialog and use the same condition to not launch the program (regardless of the initial state of the check box).

Grant
I prefer to use the Component states (as per my example above) since that is more targeted than the Feature... especially since a Component can be installed by multiple Features (Component syntax is much easier then).
Rob Mensching
A: 

It has been well documented in manual - http://wix.sourceforge.net/manual-wix3/run_program_after_install.htm

Rohit