通过功能选择| Wix SetProperty安装后启动特定功能

时间:2016-12-12 08:21:18

标签: wix

我的WixInstaller正在安装两个不同的应用程序(编辑和/或查看器)。

安装完成后,用户可以选中一个复选框,查看是否要启动该应用程序。

默认情况下,WixShellExecTarget属性的值为[#ViewerApp]。如果用户已安装编辑器,则属性应具有值[#EditorApp]。但它没有分配。

<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />

<SetProperty Id="WixShellExecTarget" Value="[#EditorApp]" After="InstallExecute" Sequence="execute"><![CDATA[EditorFeature=3]]></SetProperty>
<Property Id="WixShellExecTarget" Value="[#ViewerApp]" />

1 个答案:

答案 0 :(得分:0)

解决方案:

这是我的解决方案:

  1. 为每个可以/应该启动的应用/功能定义CustomAction

    <CustomAction Id="SetLaunchApplicationEditor" Property="WixShellExecTarget" Value="[#EditorApp]" />
    <CustomAction Id="SetLaunchApplicationViewer" Property="WixShellExecTarget" Value="[#ViewerApp]" />
    <CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
    
  2. 在安装完成的最后一页上,定义开始

    <Control Id="Finish" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Cancel="yes" Text="[ButtonText_Finish]">
        <Publish Event="EndDialog" Value="Return">1</Publish>
        <Publish Event="DoAction" Value="SetLaunchApplicationViewer"><![CDATA[&ViewerFeature=3]]></Publish>
        <Publish Event="DoAction" Value="SetLaunchApplicationEditor"><![CDATA[&EditorFeature=3]]></Publish>
        <Publish Event="DoAction" Value="LaunchApplication">LaunchApp = 1</Publish>
    </Control>
    
  3. !!

    如果仅安装了ViewerEditor,则启动此应用。如果两者都已安装,则Editor会启动,因为之后会触发DoAction

    使用复选框

    退出对话框
            <Dialog Id="HtExitDialog" 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="[ButtonText_Finish]">
                    <Publish Event="EndDialog" Value="Return">1</Publish>
                    <Publish Event="DoAction" Value="SetLaunchApplicationViewer"><![CDATA[&ViewerFeature=3]]></Publish>
                    <Publish Event="DoAction" Value="SetLaunchApplicationEditor"><![CDATA[&EditorFeature=3]]></Publish>
                    <Publish Event="DoAction" Value="LaunchApplication">LaunchApp = 1</Publish>
                </Control>
                <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Disabled="yes" Text="[ButtonText_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="[ButtonText_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 Type="CheckBox" Id="StartApp" Width="142" Height="17" X="158" Y="120" Text="Launch Application" Property="LaunchApp" CheckBoxValue="1" />
            </Dialog>