Wix:将自定义操作中的文件复制到程序目录(Windows 7)

发布于 2024-09-08 15:18:10 字数 885 浏览 0 评论 0原文

我创建了一个托管 CustomAction 将 *.MSI 中未包含的 2 个文件复制到安装目录。

虽然这在 Windows XP 中有效,但在 Windows 7 中失败。虽然日志显示文件已复制到所需位置 C:\Program Files\MyApp\,但它们实际上被复制到 C:\Users\MyUser\AppData\Local\VirtualStore\Program Files (x86)\MyApp\。 我的猜测是,这与修改程序文件夹的访问权限有关。

这就是我在 WiX 中调用自定义操作的方式:

<CustomAction 
    Id='InstallSource'
    BinaryKey='SrcInstActionDll'
    DllEntry='InstallSourceFiles'
    Execute='deferred'
    Impersonate='no'/>
<CustomAction
    Id="InstallSource.SetProperty"
    Return="check"
    Property="InstallSource"
    Value='Files=[SourceDir]$(var.SourceZipName),[SourceDir]$(var.SymbolsZipName);TargetDir=[ParentFolder]'
    Execute='immediate'/>

CustomAction 本身只是调用 File.Copy()。安装程序复制的其他文件在 Windows 7 中完美运行。只有那些使用 CustomAction 复制的文件才会出现所描述的问题。

I created a managed CustomAction to copy 2 files not included in the *.MSI to the installation directory.

While this works in Windows XP, it fails in Windows 7. Although the log say the files are copied to the desired location, C:\Program Files\MyApp\, they are actually copied to C:\Users\MyUser\AppData\Local\VirtualStore\Program Files (x86)\MyApp\.
My guess is that this has to do with access rights to modify the program folder.

This is how I call the custom action in WiX:

<CustomAction 
    Id='InstallSource'
    BinaryKey='SrcInstActionDll'
    DllEntry='InstallSourceFiles'
    Execute='deferred'
    Impersonate='no'/>
<CustomAction
    Id="InstallSource.SetProperty"
    Return="check"
    Property="InstallSource"
    Value='Files=[SourceDir]$(var.SourceZipName),[SourceDir]$(var.SymbolsZipName);TargetDir=[ParentFolder]'
    Execute='immediate'/>

The CustomAction itself simply invokes File.Copy(). Other files copied by the installer work perfectly in Windows 7. Only those files copied using the CustomAction have the described problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

吹泡泡o 2024-09-15 15:18:10

实际上,此行为是由以标准用户身份运行的 32 位应用程序(在 64 位 Windows 中)尝试写入某些特权文件夹时触发的文件系统重定向引起的。

对我来说,您的自定义操作似乎没有提升运行。由于自定义操作定义看起来正确,剩下的问题是您在哪里触发此自定义操作。

既然您提到了日志,我假设您正在运行 msiexec 并检查日志。
确保您的自定义操作在如下所示的行之后运行:

MSI (s) (BC:70) [13:34:10:669]: MSI_LUA: Elevation required to install product, will prompt for credentials
MSI (s) (BC:70) [13:34:59:528]: MSI_LUA: Credential Request return = 0x0
MSI (s) (BC:70) [13:34:59:528]: MSI_LUA: Elevated credential consent provided. Install will run elevated

不久前,我在自定义操作和 此博文 帮助我弄清楚如何解决它。这是我认为可能有帮助的另一篇文章

希望这有帮助

Indeed this behavior is caused by the file system redirection triggered when a 32 bit app (in a 64 bits Windows) running as an standard user tries to write to some privileged folder.

For me it looks like your custom action is not running elevated. Since the custom action definition looks correct the question that remains is where you are firing this custom action.

Since you mention the log I assume you are running msiexec and checking the logs.
Make sure that your custom action runs after a line that looks like:

MSI (s) (BC:70) [13:34:10:669]: MSI_LUA: Elevation required to install product, will prompt for credentials
MSI (s) (BC:70) [13:34:59:528]: MSI_LUA: Credential Request return = 0x0
MSI (s) (BC:70) [13:34:59:528]: MSI_LUA: Elevated credential consent provided. Install will run elevated

Some time ago I had a similar issue with custom actions and this blog post helped me to figure out how to fix it. This is another post that I think may help

Hope this helps

友欢 2024-09-15 15:18:10

正如您所说,我认为您的自定义操作需要提升。由于您的 CA 是一个 .Net 项目,因此将其设置为支持提升是很容易的。

请检查下一个链接,它对如何在 .Net 项目上处理 UAC 有很好的解释。

启用您的应用程序-for-uac-on-vista

希望有帮助。

Like you said, I think that your Custom Action needs elevation. Since your CA is a .Net project, it's kind of eassy to set it up to support elevation.

Please check the next link, it has a good explanation on how to handdle UAC on a .Net project.

enabling-your-application-for-uac-on-vista

Hope it helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文