Wix 延迟自定义操作访问被拒绝 [英] Wix deferred custom action access denied

查看:27
本文介绍了Wix 延迟自定义操作访问被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:客户更改了应用程序的名称.应用程序已将文件存储在 AppData 文件夹下,现在需要将该文件夹复制到新名称(并删除旧名称).

Background: Customer has changed the name of the application. The application has stored files under AppData folder and now that folder needs to be copied to new name (and delete the old).

我有 Wix 3.6 的 MSI 安装版本.我没有找到复制文件夹(仅限文件)的标准方法.所以我一直在尝试制作一个使用 xcopy 命令的自定义操作,但这似乎很难.

I have MSI installation build with Wix 3.6. I didn't find a standard way of copying folder (only file). So I have been trying to make a custom action which uses xcopy command but this seems to be very hard.

如果我立即创建 CA 并在 InstallFinalize 之后安排它,这在 WinXP 上有效,但在 Win7 上只能通过以管理员身份运行 MSI.

If I make an immediate CA and schedule it after InstallFinalize, this works on WinXP but on Win7 only by runnig the MSI as admin.

如果我进行延迟 CA,我会收到拒绝访问错误.即使我测试从用户文件夹下的文件夹复制和复制到用户文件夹下的文件夹时也会出现此错误.但是如果我用 echo 命令测试它,延迟 CA 会成功.

If I make a deferred CA I get access denied error. This error comes even when I tested to copy from and to folder under user folder. But deferred CA succeeds if I test it with echo command.

<CustomAction Id="CopyFolder_PropertyAssign" Property="CopyFolder" 
 Value="&quot;[SystemFolder]cmd.exe&quot; /c xcopy 
        &quot;[$(var.PlatformCommonAppDataFolder)]OldName&quot; 
        &quot;[$(var.PlatformCommonAppDataFolder)]NewName&quot; 
        /s /i /h /k /o /y" />
<CustomAction Id="CopyFolder" BinaryKey="WixCA" DllEntry="CAQuietExec" 
 Execute="deferred" Return="check" Impersonate="no" />

<Custom Action="CopyFolder_PropertyAssign" Before="InstallFinalize"></Custom>
<Custom Action="CopyFolder" After="CopyFolder_PropertyAssign"></Custom>

CAQuietExec:  Access denied
CAQuietExec:  Error 0x80070004: Command line returned an error.
CAQuietExec:  Error 0x80070004: CAQuietExec Failed

除了访问被拒绝之外,肯定还有其他原因,因为在用户文件夹下也会发生同样的情况,但它是什么地球?​​

There must be really something else than access denied because same happens under user folder as well but what an earth it is?

或者是否有其他解决方案(除了创建 exe 包)?

Or is there some other solutions for this (besides creating exe package)?

该文件夹位于所有用户 AppData 下.

The folder is under all user AppData.

这似乎是不可能的.选择的解决方法是立即创建 CA 并引导用户以管理员身份启动安装程序(或者在大多数情况下应该是这种情况).无论如何,感谢您的帮助!

This seems to be impossible. The chosen workaround was to make an immediate CA and guide the users to start the installer as admin (or that should be the situation in most cases). Thanks for help anyway!

推荐答案

延迟的自定义操作复制到 AppDataFolder 可能失败,因为您正在运行延迟并使用系统帐户,因此它正在尝试访问系统用户的 AppDataFolder帐户.请注意,0x80070004 不是拒绝访问,而是系统无法打开文件".

The deferred custom action copy into AppDataFolder is probably failing because you're running deferred and with the system account, so it's trying to access the user's AppDataFolder for the system account. Note that 0x80070004 is not access denied, it's "The system cannot open the file."

直接 CA 将失败,因为默认情况下这些 CA 没有提升,因此显然访问需要提升.

The immediate CA will fail because by default these CAs aren't elevated, so evidently access requires elevation.

这个问题的通常解决方案是使用 CopyFile 元素和 . 将文件从旧位置复制到新位置,使用这些位置的目录定义.如果将 delete 设置为 yes,它将移动文件,从旧位置删除它们.

The usual solution to this problem is to use the CopyFile element with . to copy the file from the old location to the new location, using directory definitions for those locations. If you set delete to yes it will move the files, deleting them from the old location.

正如 Stein 指出的那样,这确实应该在新版本首次运行时由应用程序完成.数据迁移确实是一个应用程序问题,应该在应用程序中解决,而不是通过重载安装.除了您遇到的困难之外,如果安装失败并回滚(恢复已删除的文件?)以及其他可能无法预料的问题,也存在潜在问题.

As Stein points out, this really should be done by the application when the newer version first runs. Data migration really is an application issue that should be solved in the application, and not by overloading the install. Apart from the difficulty you're having, there are also potential issues if the install fails and rolls back (restoring the removed files?) and probably other unforeseen ones.

这篇关于Wix 延迟自定义操作访问被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆