我正在尝试为我的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?
感谢您提供任何帮助
答案 0 :(得分:0)
如果我没有错过任何内容:您定义了您的CustomAction,但您没有安排它。因此它包含在文件中,但由于它没有时间表,因此根本不会被调用
因此,InstallExecuteSequence
中的条目丢失了。另请注意,属性Value
的{{1}}包含应调用的命令行,因此在您的情况下QtExecCmdLine
必须位于路径中。
另请注意,CustomAction的UIStart.exe
- 属性必须与相关属性的Id
匹配,即
Id
请参阅official documentation或WiX tutorial @Tramontana,您可以找到有关如何实施该示例的示例。