如何在卸载时立即生成WIX执行命令
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何在卸载时立即生成WIX执行命令相关的知识,希望对你有一定的参考价值。
我有一个使用WIX安装应用程序的java桌面应用程序。在安装时,WIX正在创建一个位于{...} / AppData / Local文件夹中的文件夹。然后,应用程序在执行应用程序期间使用子文件夹和文件填充此文件夹。
我们注意到在卸载应用程序时,不删除此文件夹(如果已填充,如果它是空的,则通过RemoveFolder elelemt删除),这会导致不愉快。
对此事的研究表明,RemoveFolder元素只能删除空文件夹,即。没有子文件夹和文件。为了解决这个问题,我提出了执行批处理文件的解决方案,该代码用于通过自定义操作删除整个文件夹,包括子文件夹和文件。我想把这个文件放在应用程序的安装路径中,这与放置我要删除的文件夹的位置不同。
打开安装/卸载应用程序的日志记录后,我发现此自定义操作未按正确的顺序执行,即。它在删除安装文件夹后执行,从而永远不会运行批处理文件。
这是我的WIX InstallExecuteSequence:
<InstallExecuteSequence>
<Custom Action='RemoveAlelionFolder' After="InstallFiles">
Installed AND NOT UPGRADINGPRODUCTCODE
</Custom>
<RemoveExistingProducts After="InstallValidate"/>
</InstallExecuteSequence>
<CustomAction Id='RemoveAlelionFolder' ExeCommand='[INSTALLDIR]remove.bat' Directory="INSTALLDIR" Execute="deferred" Return='asyncNoWait' />
以下是安装/卸载日志文件的一部分:
Action ended 15:20:21: RemoveShortcuts. Return value 1.
Action start 15:20:21: RemoveFiles.
MSI (s) (8C:BC) [15:20:21:111]: Counted 9 foreign folders to be removed.
MSI (s) (8C:BC) [15:20:21:111]: Removing foreign folder: C:UsersPublicDesktop
MSI (s) (8C:BC) [15:20:21:111]: Removing foreign folder: C:ProgramDataMicrosoftWindowsStart MenuProgramsCompany
MSI (s) (8C:BC) [15:20:21:111]: Removing foreign folder: C:Users{username}AppDataLocalCompany **<-- This is not working if folder contains files**
MSI (s) (8C:BC) [15:20:21:111]: Removing foreign folder: C:ProgramDataMicrosoftWindowsStart MenuProgramsCompany
MSI (s) (8C:BC){Removing a lot of folders here}
MSI (s) (8C:BC) [15:20:21:112]: Doing action: RemoveFolders
MSI (s) (8C:BC) [15:20:21:112]: Note: 1: 2205 2: 3: ActionText
Action ended 15:20:21: RemoveFiles. Return value 1.
Action start 15:20:21: RemoveFolders.
MSI (s) (8C:BC) [15:20:21:113]: Doing action: CreateFolders
MSI (s) (8C:BC) [15:20:21:113]: Note: 1: 2205 2: 3: ActionText
Action ended 15:20:21: RemoveFolders. Return value 1.
Action start 15:20:21: CreateFolders.
MSI (s) (8C:BC) [15:20:21:114]: Doing action: InstallFiles
MSI (s) (8C:BC) [15:20:21:114]: Note: 1: 2205 2: 3: ActionText
Action ended 15:20:21: CreateFolders. Return value 1.
MSI (s) (8C:BC)
MSI (s) (8C:BC) [15:20:21:118]: Note: 1: 2205 2: 3: Patch
MSI (s) (8C:BC) [15:20:21:118]: Note: 1: 2228 2: 3: Patch 4: SELECT `Patch`.`File_`, `Patch`.`Header`, `Patch`.`Attributes`, `Patch`.`Sequence`, `Patch`.`StreamRef_` FROM `Patch` WHERE `Patch`.`File_` = ? AND `Patch`.`#_MsiActive`=? ORDER BY `Patch`.`Sequence`
MSI (s) (8C:BC) [15:20:21:118]: Note: 1: 2205 2: 3: MsiSFCBypass
MSI (s) (8C:BC) [15:20:21:118]: Note: 1: 2228 2: 3: MsiSFCBypass 4: SELECT `File_` FROM `MsiSFCBypass` WHERE `File_` = ?
MSI (s) (8C:BC) [15:20:21:118]: Note: 1: 2205 2: 3: MsiPatchHeaders
MSI (s) (8C:BC) [15:20:21:118]: Note: 1: 2228 2: 3: MsiPatchHeaders 4: SELECT `Header` FROM `MsiPatchHeaders` WHERE `StreamRef` = ?
Action start 15:20:21: InstallFiles.
MSI (s) (8C:BC) [15:20:21:118]: Doing action: RemoveAlelionFolder **<-- Here is action for removing folder w/ files**
MSI (s) (8C:BC) [15:20:21:118]: Note: 1: 2205 2: 3: ActionText
Action ended 15:20:21: InstallFiles. Return value 1.
Action start 15:20:21: RemoveAlelionFolder.
MSI (s) (8C:BC) [15:20:21:119]: Doing action: CreateShortcuts
MSI (s) (8C:BC) [15:20:21:119]: Note: 1: 2205 2: 3: ActionText
一些研究工作:http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Removing-Folders-td703071.html Removing files when uninstalling WiX How to add a WiX custom action that happens only on uninstall (via MSI)? https://stackoverflow.com/questions/320921/how-to-add-a-wix-custom-action-that-happens-only-on-uninstall-via-msi
解决了!
我必须运行自定义操作'After ='InstallInitialize',以便它在代码流中的正确位置运行。
<InstallExecuteSequence>
<Custom Action='RemoveAlelionFolder' After="InstallInitialize">
Installed AND NOT UPGRADINGPRODUCTCODE
</Custom>
<RemoveExistingProducts After="InstallValidate"/>
</InstallExecuteSequence>
以上是关于如何在卸载时立即生成WIX执行命令的主要内容,如果未能解决你的问题,请参考以下文章