views:

433

answers:

3

Hello,

I'm making an installation with WiX that have "Launch an application after install" checkbox. The goal is to have reaction on set checkbox as well as on unset checkbox. I case checkbox is set I need to run an application. In case checkbox is not set I need to run the same application but with command line argument.

Here is a part of my wix script.

<CustomAction Id="StartConfigManagerOnExit" FileKey="ParamsShower.exe" ExeCommand="" Execute="immediate" Impersonate="yes" Return="asyncNoWait" />
<CustomAction Id="StartUpgradeConfigOnExit" FileKey="ParamsShower.exe" ExeCommand="/upgrade" Execute="immediate" Impersonate="yes" Return="asyncNoWait" />
<UI>
  <Publish Dialog="ExitDialogEx" Control="Finish" Order="1" Event="DoAction" Value="StartConfigManagerOnExit">LAUNCHAPPONEXIT = 1</Publish>
  <Publish Dialog="ExitDialogEx" Control="Finish" Order="1" Event="DoAction" Value="StartUpgradeConfigOnExit">LAUNCHAPPONEXIT = 0</Publish>

  <Publish Dialog="ExitDialogEx" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>

 <Dialog Id="ExitDialogEx" Width="370" Height="270" Title="[ProductName] Setup">
     <Control Id="LaunchCheckBox" Type="CheckBox" X="135" Y="190" Width="220" Height="40" Property="LAUNCHAPPONEXIT" Hidden="yes" CheckBoxValue="1" Text="Launch an app">
        <Condition Action="show">NOT Installed</Condition>
     </Control>
 </Dialog>
 <InstallUISequence>
     <Show Dialog="ExitDialogEx" OnExit="success" />
 </InstallUISequence>
 <AdminUISequence>
     <Show Dialog="ExitDialogEx" OnExit="success" />
 </AdminUISequence> 
</UI>

An installation starts the application when LaunchCheckBox is set. But doesn't run it in case checkbox is not set. Please help.

A: 

you need to add initialize custom action for your property <CustomAction ID="InitLAUNCHAPPONEXIT" Property="LAUNCHAPPONEXIT" Value="0" Return="check"/> and than add it to InstallUISequence before show exit dialog, or simply add your property to product <Property Id="LAUNCHAPPONEXIT" Value="0" />

necrostaz
I've set <Property Id="LAUNCHAPPONEXIT" Value="0" /> to the <Product>.Now if checkbox is set the StartUpgradeConfigOnExit (LAUNCHAPPONEXIT = 0) fires. If checkbox is not set nothing happened.
Maxs
A: 

I've found an answer. Looks like checkbox property is not equal to 0 when unchecked. Simply change the condition "LAUNCHAPPONEXIT = 0" with "NOT LAUNCHAPPONEXIT" solves the situation.

Make default:

<Property Id="LAUNCHAPPONEXIT" Value="1" />

Then correct the conditions (corrected with sascha's comment):

<Publish Dialog="ExitDialogEx" Control="Finish" Order="1" Event="DoAction" Value="StartConfigManagerOnExit">LAUNCHAPPONEXIT</Publish>
<Publish Dialog="ExitDialogEx" Control="Finish" Order="1" Event="DoAction" Value="StartUpgradeConfigOnExit">NOT LAUNCHAPPONEXIT</Publish>
Maxs
+1  A: 

A checkbox has no value at all when unchecked, so rather than use the 1/0 notation you can simply use

LAUNCHAPPONEXIT

and

Not LAUNCHAPPONEXIT
sascha