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

发布于 2024-08-21 21:40:50 字数 2136 浏览 4 评论 0原文

我正在使用 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 时,安装将启动应用程序。但如果未设置复选框,它不会运行它。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

嘿咻 2024-08-28 21:40:50

我找到了答案。看起来未选中时复选框属性不等于 0。只需将条件“LAUNCHAPPONEXIT = 0”更改为“NOT LAUNCHAPPONEXIT”即可解决此问题。

设为默认:

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

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>
书间行客 2024-08-28 21:40:50

未选中时,复选框根本没有任何值,因此您可以简单地使用

LAUNCHAPPONEXIT

和 ,而不是使用 1/0 表示法

Not LAUNCHAPPONEXIT

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
跨年 2024-08-28 21:40:50

您需要为您的属性添加初始化自定义操作,

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

然后在显示退出对话框之前将其添加到 InstallUISequence,或者只需将您的属性添加到产品.

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" />.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文