gpt4 book ai didi

WIX - 如何在 ="install"/"both"上使用 RemoveFolderEx?

转载 作者:行者123 更新时间:2023-12-05 07:59:13 24 4
gpt4 key购买 nike

我试图在“安装”(和“卸载”)时删除文件夹,但该文件夹仅在“卸载”时删除。
任何提示如何做到这一点?

<Property Id="PACKAGEFOLDER">
<RegistrySearch Root="HKLM" Key="$(var.RegKey)" Type="raw" Id="PKGFOLDER_REGSEARCH" Name="PkgDir" />
</Property>

<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="PACKAGE" Name="$(var.PkgFolder)">
<Component Id="PackagesFiles" Guid="$(var.FilesGUID)">
<RegistryValue Root="HKLM" Key="$(var.RegKey)" Name="PkgDir" Type="string" Value="[PACKAGE]" KeyPath="yes" />
<util:RemoveFolderEx On="both" Property="PACKAGEFOLDER" />
</Component>
</Directory>
</Directory>
</Directory>

刚刚注意到:如果 RegKey 在安装开始前在注册表中可用,它将起作用:

WixRemoveFoldersEx: Recursing path: C:\Program Files (x86)... for row: wrf945C37509CA5EEDC2367957D5F072DFF. MSI (s) (94!A8) [19:17:55:185]: PROPERTY CHANGE: Adding _UNOPACKAGEFOLDER_0 property. Its value is 'C:\Program Files (x86)... MSI (s) (94:D4) [19:17:55:185]: Doing action: CostInitialize

但如果 R​​egKey 不在注册表中,日志会显示:

WixRemoveFoldersEx: Error 0x80070057: Missing folder property: APPLICATIONFOLDER for row: wrfA308D08284221970F6338358BFB75917 CustomAction WixRemoveFoldersEx returned actual error code 1603 but will be translated to success due to continue marking MSI (s) (84:50) [19:29:08:529]: Doing action: CostInitialize

是否可以在设置“PACKAGEFOLDER”属性之前写入 RegKey?

最佳答案

我假设您在此文件夹中也有应该删除的文件。如果没有包含文件的(任意)子目录,则应该直接使用 Windows Installer 的 RemoveFile 表。因为它只会删除文件夹,如果它是空的,添加一个额外的条目将删除其中的文件,例如:

<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="PACKAGE" Name="$(var.PkgFolder)">
<Component Id="PackagesFiles" Guid="$(var.FilesGUID)">
<RegistryValue Root="HKLM" Key="$(var.RegKey)" Name="PkgDir" Type="string" Value="[PACKAGE]" KeyPath="yes" />
<RemoveFile Id="RemovePACKAGEFolderFiles" Directory="PACKAGE" Name="*.*" On="both" />
<RemoveFolder Id="RemovePACKAGEFolder" Directory="PACKAGE" On="both" />
</Component>
</Directory>
</Directory>
</Directory>

这样您就不必处理任何属性设置。如果您有其他包含文件的子目录,您也必须对这些文件重复此操作。

另一种方法是在系统上下文中创建一个延迟的自定义操作,它将完全删除文件夹,例如在 VBScript 中。

关于WIX - 如何在 ="install"/"both"上使用 RemoveFolderEx?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22153882/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com