如何使用 Wix 安装程序将文件权限递归应用到现有文件夹?

发布于 2024-12-28 13:14:14 字数 889 浏览 0 评论 0原文

我们有一个使用 Wix 3.5 为我们的应用程序创建的安装程序。我们的应用程序的用户在通用应用程序数据文件夹中拥有现有数据,我们希望“修复”其权限,以便我们的用户不再需要成为其 PC 上的管理员。

因此,在安装过程中,我将以下部分添加到 Wix 项目中,以便它修改我们的文件夹权限。这对于新用户来说非常有用,但这些文件夹中的任何现有文件仍然保留旧的 ACL,并且不允许非管理员用户读取/修改它们。

  <Directory Id="CommonAppDataFolder">
    <Directory Id="CommonAppOurCompany" Name="OurCompany">
      <Directory Id="MODELLIBPATH" Name="Library">
        <Component Id="LibraryUserPermissions" Guid="12BC499B-4601-449F-9515-4C58A8F29603">
          <CreateFolder>
            <util:PermissionEx GenericRead="yes" GenericWrite="yes" GenericExecute="yes" Delete="yes" DeleteChild="yes" User="Users" Domain="[MachineName]"/>
          </CreateFolder>
        </Component>
      </Directory>
    </Directory>
  </Directory>

如何才能将新的 ACL 递归地应用于文件夹及其子文件夹中的每个文件,而不删除或修改文件(除其安全设置外)?

We have an installer created using Wix 3.5 for our application. We have users of our application that have existing data in the Common Application Data Folder that we would like to "fix" the permissions on so that our users no longer need to be Administrators on their PCs.

So during the install I added the following section to the Wix Project so that it modifies our folders permissions. This works great for new users, but any existing files in those folders still retain the old ACL and don't allow non-admin users to read/modify them.

  <Directory Id="CommonAppDataFolder">
    <Directory Id="CommonAppOurCompany" Name="OurCompany">
      <Directory Id="MODELLIBPATH" Name="Library">
        <Component Id="LibraryUserPermissions" Guid="12BC499B-4601-449F-9515-4C58A8F29603">
          <CreateFolder>
            <util:PermissionEx GenericRead="yes" GenericWrite="yes" GenericExecute="yes" Delete="yes" DeleteChild="yes" User="Users" Domain="[MachineName]"/>
          </CreateFolder>
        </Component>
      </Directory>
    </Directory>
  </Directory>

What can I do to recursively apply the new ACL to each file in the folder and its subfolders, without deleting or modifying the files (other than their security settings)?

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

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

发布评论

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

评论(2

甜心 2025-01-04 13:14:14

通常,安装程序会创建并设置权限,以便新文件夹和文件将继承。在您的情况下,您需要编写一个自定义操作来调用 cacls 或类似的递归结构并应用权限。据我所知,MSI 或 WiX 没有内置功能可以做到这一点。

Normally an installer creates and sets the permissions so that new folders and files will inherit. In your situation you'll need to write a custom action to call cacls or similar to recursive the structure and apply the permissions. There's no built in ability in MSI or WiX to do this to the best of my knowledge.

空心↖ 2025-01-04 13:14:14
Folder permission:
<ComponentGroup Id="" Directory="" Source="">
  <Component Id="CompID" Guid="*">
    <CreateFolder>
      <Permission User="Administrators" GenericAll="yes"/>
      <Permission User="Users" GenericAll="no" GenericRead="yes" GenericExecute="yes"/>
      <---- keep adding required user permission --->
    </CreateFolder>

文件权限:
有点棘手。我尝试在 Customaction 中使用 Cacl.exe 但没有帮助。首先,您需要删除现有文件以清除现有 ACL,然后创建新文件:

<RemoveFile Id="fileID" Name="FileName" On="both" />
    <File Id ="fileID" KeyPath="yes">
      <Permission User="Administrators" GenericAll="yes"/>
      <Permission User="Users" GenericAll="no" GenericRead="yes" GenericExecute="yes" GenericWrite="no"/>
    </File>
  </Component>
</ComponentGroup>
Folder permission:
<ComponentGroup Id="" Directory="" Source="">
  <Component Id="CompID" Guid="*">
    <CreateFolder>
      <Permission User="Administrators" GenericAll="yes"/>
      <Permission User="Users" GenericAll="no" GenericRead="yes" GenericExecute="yes"/>
      <---- keep adding required user permission --->
    </CreateFolder>

File Permission:
Little tricky. I tried using Cacl.exe in Customaction but did not help. First you need to remove existing file to clear existing ACL then create new file:

<RemoveFile Id="fileID" Name="FileName" On="both" />
    <File Id ="fileID" KeyPath="yes">
      <Permission User="Administrators" GenericAll="yes"/>
      <Permission User="Users" GenericAll="no" GenericRead="yes" GenericExecute="yes" GenericWrite="no"/>
    </File>
  </Component>
</ComponentGroup>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文