WiX:无法处理“安装后启动应用程序”复选框= 0

时间:2010-02-16 10:54:24

标签: wix custom-action

我正在使用具有“安装后启动应用程序”复选框的WiX进行安装。 目标是在设置复选框以及取消设置复选框时做出反应。如果设置了复选框,我需要运行一个应用程序。如果没有设置复选框,我需要使用命令行参数运行相同的应用程序。

这是我的WiX脚本的一部分。

<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>

安装LaunchCheckBox时,安装会启动应用程序。但是如果没有设置复选框,它就不会运行它。

3 个答案:

答案 0 :(得分:4)

我找到了答案。未选中时,看起来checkbox属性不等于0。只需用“NOT LAUNCHAPPONEXIT”改变条件“LAUNCHAPPONEXIT = 0”即可解决问题。

默认:

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

然后纠正条件(用sascha的评论更正):

<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>

答案 1 :(得分:3)

取消选中复选框时根本没有值,所以不要使用1/0表示法,只需使用

LAUNCHAPPONEXIT

Not LAUNCHAPPONEXIT

答案 2 :(得分:0)

您需要为您的媒体资源添加初始化自定义操作

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

然后在show exit对话框之前将其添加到InstallUISequence,或者只是将您的属性添加到产品<Property Id="LAUNCHAPPONEXIT" Value="0" />