2

I'm making an installation with WiX that have a "Launch an application after install" checkbox. The goal is to have a reaction on settting the checkbox as well as on unsetting the checkbox. In case the checkbox is set, I need to run an application. In case the 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 it doesn't run it in case the checkbox is not set.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Maxs
  • 193
  • 3
  • 9

3 Answers3

5

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
  • 193
  • 3
  • 9
3

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
saschabeaumont
  • 22,080
  • 4
  • 63
  • 85
0

You need to add initialize custom action for your property,

<CustomAction ID="InitLAUNCHAPPONEXIT" 
              Property="LAUNCHAPPONEXIT" 
              Value="0" 
              Return="check"/> 

and then add it to InstallUISequence before show exit dialog, or simply add your property to product <Property Id="LAUNCHAPPONEXIT" Value="0" />.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
necrostaz
  • 380
  • 1
  • 2
  • 6
  • I've set to the . Now if checkbox is set the StartUpgradeConfigOnExit (LAUNCHAPPONEXIT = 0) fires. If checkbox is not set nothing happened. – Maxs Feb 16 '10 at 12:30