无法删除文件夹WIX安装程序

经理人

我有WIX安装程序安装的服务:

<Component Id="cmp_myService" Guid="{5FC8815E-33T8-4C3D-9654-849EE4CB1E22}">
    <File Id="f_myService" Name="MyService.exe" Source="$(var.SourcePath)MyService.exe" KeyPath="yes" />
    <ServiceInstall Id="si_myServiceInstall" Name="My Service" DisplayName="It is my service" Type="ownProcess" Interactive="yes" Start="auto" ErrorControl="normal" Description="Here is some description" />
    <ServiceControl Id="sc_startStopMyService" Name="My Service" Start="install" Stop="both" Remove="uninstall" Wait="yes" />
</Component>

另外,我有一个自定义操作ca1_removeInstallDirOnUnsinstall,该操作会删除一个包含所有内容的文件夹(MyService.exe在此文件夹内)

<Custom Action="ca1_removeInstallDirOnUnsinstall" After="DeleteServices"><![CDATA[REMOVE="ALL"]]></Custom>

我将这个自定义操作安排为DeleteServices在执行序列中的一个接一个的操作之后立即运行我认为此时MyService.exe应停止并删除。但是我得到一个例外Access to the path 'MyService.exe' is denied,这意味着该服务尚未删除。为什么会发生这种情况,应该安排我的自定义操作以确保已删除该服务?

相关日志文件:

MSI (s) (64:3C) [08:42:32:597]: Doing action: StopServices
MSI (s) (64:3C) [08:42:32:597]: Note: 1: 2205 2:  3: ActionText 
Action ended 8:42:32: UnpublishFeatures. Return value 1.
Action start 8:42:32: StopServices.
MSI (s) (64:3C) [08:42:32:597]: Doing action: DeleteServices
MSI (s) (64:3C) [08:42:32:597]: Note: 1: 2205 2:  3: ActionText 
Action ended 8:42:32: StopServices. Return value 1.
Action start 8:42:32: DeleteServices.
MSI (s) (64:3C) [08:42:32:597]: Doing action: ca1_removeInstallDirOnUnsinstall
MSI (s) (64:3C) [08:42:32:597]: Note: 1: 2205 2:  3: ActionText 
Action ended 8:42:32: DeleteServices. Return value 1.
MSI (s) (64:80) [08:42:32:597]: Invoking remote custom action. DLL: C:\windows\Installer\MSIA125.tmp, Entrypoint: RemoveInstallDirRecursively
MSI (s) (64:B8) [08:42:32:597]: Generating random cookie.
MSI (s) (64:B8) [08:42:32:597]: Created Custom Action Server with PID 6176 (0x1820).
MSI (s) (64:98) [08:42:32:644]: Running as a service.
MSI (s) (64:B4) [08:42:32:644]: Hello, I'm your 32bit Impersonated custom action server.
Action start 8:42:32: ca1_removeInstallDirOnUnsinstall.
SFXCA: Extracting custom action to temporary directory: C:\windows\Installer\MSIA125.tmp-\
SFXCA: Binding to CLR version v4.0.30319
Calling custom action CustomAction!CustomAction.FilesAndFoldersCustomAction.RemoveInstallDirRecursively
Access to the path 'MyService.exe' is denied.
斯坦·奥斯穆尔

InstallFinalize:在DeleteServices发生之前InstallFiles我想msiexec.exe可能在重大升级中可能在文件夹上加了锁,有可能重新安装,但我不确定(使用: perfmon.exe procexp64.exe查找锁)。您可以将Delete操作放在前面InstallFinalize(这样会结束更改系统的提升操作)。此位置应该可以,但不能保证。“核对”整个文件夹不是一个好习惯。

最佳实践:通常,您不应该删除整个文件夹(这很有风险-弄乱了某些东西,最终可能会删除一半的计算机。说真的。我已经看到了这种情况。不是使用MSI,而是使用“清理EXE”)。我会将日志文件放在用户个人资料或之外的其他位置%ProgramFiles%或使用event log甚至数据库将其上传到在线,以避免遗留太多文件。

可接受的剩余部分:我认为不应尝试自动卸载日志文件和其他用户数据。为什么?它们是用户数据-换句话说:它们属于用户。您不能只是将其立即删除?我只是将数据保留在原处,以防他们想要分析它们或重新安装应用程序(后者对于许可证密钥尤为重要-您将它们留在后面吗?)。

WiX:WiX具有多个内置结构,可帮助删除文件和文件夹。有内置的MSI变体(RemoveFileRemoveFolder)只能通过通配符或名称删除文件。再有就是RemoveFileEx通过描述鲍勃Arnson(WiX的开发团队)请阅读博客文章。我相信它可以递归地完成这项工作(所有子文件夹)。如您所知,由于我赞成其他清除方法,因此我并没有太多使用这些构造。坦率地说,我只是尝试在PDF或在线KDB文章中记录清理过程。


链接:

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章