c++ - 如何在安装期间将文件夹共享访问权限设置为 MSI 中当前登录的用户(或任何其他本地用户)?
问题描述
使用的包装工具:WIX。
自定义操作是用 C++ 编写的。
在安装过程中,我的 MSI 在 ProgramData 中创建了一个文件夹“X”,在安装结束时,我需要为当前登录的用户(或 PC 中的任何本地用户,此输入将在安装过程中由用户提供)提供文件夹共享访问权限,我找不到任何可以帮助我解决此问题的 WIX 元素或 C++ API。
我发现在 wix 中使用元素我可以为文件夹提供权限(文件夹属性的安全选项卡),但我找不到提供共享权限的 Wix 元素/C++ API。(文件属性的共享选项卡)现在如果你看到“ “每个人”都有读取权限,通过我的 MSI,我应该能够在共享中为任何用户提供完全访问权限(完全控制)。
解决方案
WiX 在其 Util 扩展中具有此功能:
- https://github.com/wixtoolset/Util.wixext/blob/25973d520d0e5102421549bae8f3e17b720485e9/src/test/WixToolsetTest.Util/TestData/UsingFileShare/PackageComponents.wxs
- https://github.com/wixtoolset/wix3/blob/bda1c281cb0349007d767d5404d6da87076d7d94/test/data/Extensions/UtilExtension/FileShareTests/product.wxs
文档:
- https://wixtoolset.org/documentation/manual/v3/xsd/util/fileshare.html
- https://wixtoolset.org/documentation/manual/v3/xsd/util/filesharepermission.html
Util dll 中还有许多其他 WiX 特殊功能:https ://wixtoolset.org/documentation/manual/v3/xsd/util/
一个具体的模型示例:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Product Id="*" Name="WixFolderShare" Language="1033" Version="1.0.0.0" Manufacturer="Someone" UpgradeCode="b3d89acb-71d9-48ab-a3df-886d49965ea3">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MediaTemplate EmbedCab="yes" />
<!--<UIRef Id="WixUI_Mondo" />--> <!-- Diabled main GUI -->
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<Feature Id="ProductFeature" Title="WixFolderShare" Level="1" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="Test Folder">
<Component Feature="ProductFeature">
<File Source="$(env.SystemRoot)\notepad.exe" />
<util:User Id="Everyone" Name="Everyone" />
<!-- Create Share with share permissions -->
<util:FileShare Id="TestShare" Name="TestShareName" Description="This is a test share.">
<util:FileSharePermission User="Everyone" GenericAll="yes"/>
</util:FileShare>
<!-- NTFS ACL permissions -->
<CreateFolder>
<util:PermissionEx User="Everyone" GenericAll="yes" />
</CreateFolder>
</Component>
</Directory>
</Directory>
</Directory>
</Product>
</Wix>
推荐阅读
- javascript - 将数据解析为 JavaScript 数组
- java - 在 Node.js 中使用 BodyParser 解析 JSON 数组
- scala - Scalaz,*语法类的目的
- ios - keyboardWillShowNotification 被解雇时调用了两次
- php - PHP foreach 循环返回空值
- vagrant - 厨师食谱中nexus_api的默认属性覆盖无法更新值
- php - 简单应用的 MVC
- c - 是否可以恢复单个链表的头指针?
- phpspreadsheet - PHPSpreadsheet --> 如何删除单个图像/绘图
- arrays - TypeScript 中混合类型的数组