Python WIX工具集安装后执行文件

Python WIX工具集安装后执行文件,python,wix,custom-action,Python,Wix,Custom Action,我正试图为我的python应用程序准备一个安装文件。我已经创建了安装文件并安装了,它工作得很好。现在,我想在安装结束时添加一个自定义操作,该操作将执行一个文件,该文件将在用户首次启动程序之前设置我的数据库。以下是我目前的代码: Test.wxs <?xml version='1.0' encoding='windows-1252'?> <Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'> <Product

我正试图为我的python应用程序准备一个安装文件。我已经创建了安装文件并安装了,它工作得很好。现在,我想在安装结束时添加一个自定义操作,该操作将执行一个文件,该文件将在用户首次启动程序之前设置我的数据库。以下是我目前的代码:

Test.wxs

<?xml version='1.0' encoding='windows-1252'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>

  <Product Name='First App' Id='625F5886-BA33-4332-8831-18960B95D1EF' UpgradeCode='D94D7010-273B-46CA-848B-607C9DF55B3F'
Language='1033' Codepage='1252' Version='1.0.0' Manufacturer='Fake Inc'>

    <Package Id='*' Keywords='Installer' Description="Fake App will do everything"
  Comments='Fake App is a registered trademark of Acme Ltd.' Manufacturer='Fake Inc'
  InstallerVersion='100' Languages='1033' Compressed='yes' SummaryCodepage='1252' />

    <Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />

    <Icon Id="test.ico" SourceFile="C:\xxx\xxx\xxx\test.ico"/>

    <Directory Id="TARGETDIR" Name="SourceDir">

        <Directory Id="PersonalFolder"  Name="PersonalFolder">
            <Directory Id="Fake"  Name="Fake">
                <Directory Id="INSTALLLOCATION" Name="Fake App">
                    <Component Id='MainExecutable' Guid='D6388D5A-845A-4EE6-84D5-75E30E201E5F'>
            <File Id='UIStart.bat' Name='UIStart.bat'  DiskId='1' Source="C:\xxx\xxx\xxx\UIStart.bat" Vital='yes'/>
            <File Id='main.py' Name='main.py'  DiskId='1' Source="C:\xxx\xxx\xxx\main.py" Vital='yes'/>
            <File Id='UIStart.exe' Name='UIStart.exe'  DiskId='1' Source="C:\xxx\xxx\xxx\UIStart.exe" Vital='yes'/>
            <RemoveFolder Id="Fake Inc" On="uninstall"/>
                    </Component>
                </Directory>
            </Directory>
        </Directory>

        <Directory Id="ProgramMenuFolder">
                <Directory Id="ApplicationProgramsFolder" Name="Fake">
                    <Component Id="ApplicationShortcutStartMenu" Guid="{b449021b-a21f-4700-9c44-759e3fb77c47}">
                        <Shortcut Id="ApplicationStartMenuShortcut"
                            Name="Fake App"
                            Description="Fake App shortcut"
                            Target="[#UIStart.bat]"
                            WorkingDirectory="INSTALLLOCATION"
                            Icon ="test.ico"/>

                        <Shortcut Id="UninstallProduct"
                              Name="Uninstall Fake App"
                              Target="[System32Folder]msiexec.exe"
                              Arguments="/x [ProductCode]"
                              Description="Uninstalls My Application" />

                        <RemoveFolder Id="ProgramMenuFolder" On="uninstall"/>
                        <RegistryValue
                            Root="HKCU"
                            Key="Software/Fake"
                            Name="installed"
                            Type="integer"
                            Value="1"
                            KeyPath="yes"/>
                    </Component>
                </Directory>
        </Directory>


        <Directory Id="DesktopFolder"  Name="Desktop">
            <Component Id="ApplicationShortcutDesktop" Guid="{A072CB7F-5598-4d1c-85E3-C119659B1B19}">
                <Shortcut Id="ApplicationDesktopShortcut"
                    Name="TFake App"
                    Description="Comment field in your shortcut"
                    Target="[#UIStart.bat]"
                    WorkingDirectory="INSTALLLOCATION"
                    Icon ="test.ico"/>
                <RemoveFolder Id="DesktopFolder" On="uninstall"/>
                <RegistryValue
                    Root="HKCU"
                    Key="Software/Fake"
                    Name="installed"
                    Type="integer"
                    Value="1"
                    KeyPath="yes"/>
                </Component>
        </Directory>
    </Directory>

    <Property Id="JAVA_CURRENT_VERSION">
      <RegistrySearch Id="JRE_KEY" Root="HKLM" Key="SOFTWARE\JavaSoft\Java Runtime Environment" Name="CurrentVersion" Type="raw" Win64="no" />
    </Property>
    <Condition Message="Java not installed  Please install JRE 1.6 or later."><![CDATA[(Installed OR JAVA_CURRENT_VERSION) AND JAVA_CURRENT_VERSION >= "1.6"]]></Condition> 


    <Feature Id='Complete' Level='1' ConfigurableDirectory ='INSTALLLOCATION'>
        <ComponentRef Id='MainExecutable' />
        <ComponentRef Id='ApplicationShortcutStartMenu' />
        <ComponentRef Id='ApplicationShortcutDesktop' />

    </Feature >

    <Property Id="QtExecCmdLine" Value="UIStart.exe"/>
    <CustomAction Id="QtExecCmdLine" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="check" />

    <InstallExecuteSequence>
      <Custom Action="QtExecCmdLine" After="InstallFinalize"/>
    </InstallExecuteSequence>


   </Product>


</Wix>
当编译并运行该程序时,程序将安装,但我收到以下错误:

安装程序在安装此程序包时遇到意外错误。这可能表明此软件包存在问题。错误代码是2762

如何在安装结束时自动执行UIStart.exe


如果我没有错过任何东西,感谢您提供的所有帮助:您定义了CustomAction,但没有安排它。因此它包含在文件中,但由于它不在任何计划中,因此根本不会被调用。 因此,InstallExecuteSequence中的条目丢失。还要注意,属性qtexecmdline的值包含应调用的命令行,因此在您的情况下,UIStart.exe必须位于路径中。 还请注意,CustomAction的Id属性必须与相关属性的Id匹配,即

<Property Id="QtExecCmdLine" Value="UIStart.exe"/>
<CustomAction Id="QtExecCmdLine" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="check" />

请参阅或,您可以从中找到有关如何实现它的示例。

我刚刚添加了InstallExecuteSequence,并匹配了ID,但现在出现以下错误:安装程序在安装此软件包时遇到意外错误。这可能表明此软件包存在问题。错误代码为2762可能是您在InstallInitialize之前或InstallFinalize之后安排了自定义操作?延迟的自定义操作必须在该范围内。您可以找到一个非常容易理解和良好的单相描述。尝试在InstallExecuteSequence中安排它Before=InstallFinalize,然后您应该消除此错误。当我在InstallExecuteSequence中添加Before=InstallFinalize时,我没有收到错误,但程序没有安装。如回答中所述:属性的Value属性包含将要执行的命令行。现在,如果没有示例代码中给出的任何路径,UIStart.exe必须位于路径中,例如,尝试将此exe放入WindowsFolder\system32中。有关安装过程中发生的情况的详细信息,请尝试在安装过程中创建日志文件,例如,在命令行上调用以下命令:msiexec/i/l myMSI.log当然,用文件名替换myMSI.msi。然后,您将在同一路径中拥有一个日志文件myMSI.log,您可以在该路径中扫描自定义操作。