Wix:使用permissionEx设置安装文件夹中的文件夹的权限

编程入门 行业动态 更新时间:2024-10-24 08:30:14
本文介绍了Wix:使用permissionEx设置安装文件夹中的文件夹的权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我正在为使用Wix的ASP.NET MVC Web应用程序创建一个安装程序,我需要为站点中的特定文件夹设置IIS_WPG的写入权限。我发现一个例子(我还没有得到它的工作)如何做到这一点与cacls.exe:

< CustomAction Id =PermissionAppDataDirectory =TARGETDIR ExeCommand =& quot; [SystemFolder] cacls.exe& quot; & quot; [INSTALLDIR] \Content\uploads& ; / T / E / G IIS_WPG:MReturn =check/>

然而,我听说过 PermissionEx 是更好,因为它修改ACL而不是覆盖(虽然/ E修饰符在这里声称做同样的),所以我更喜欢使用,如果可能的话。我可以为 PermissionEx 找到安装目录和所有子文件夹的权限的唯一示例 - 我不想这样做。

如何使用 PermissionEx 修改中的单个文件夹的权限安装文件夹?

更新

好的,这是我到目前为止基于阎的答案下面和一堆的其他示例在线

我的文件夹结构....

<片断> <! - 默认为C:\如果是主磁盘 - > < Property Id =ROOTDRIVE><![CDATA [C:\]]>< / Property> < Directory Id =TARGETDIRName =SourceDir> <! - 将引用C:\inetpub - > <目录ID =INETPUBName =Inetpub> <! - 将引用c:\Inetpub\wwwroot - > <目录ID =WWWROOTName =wwwroot> <! - 将引用c:\Inetpub\wwwroot\Demowebsite - > < Directory Id =INSTALLFOLDERName =DemoWebsite> < Directory Id =CONTENTName =Content> < Directory Id =UPLOADName =upload> < / Directory> < / Directory> < / Directory> < / Directory> < / Directory> < / Directory> < / Fragment>

Yan的建议

code><片断> < DirectoryRef Id =UPLOAD> < Component Id =SetFolderPermissionsGuid =*> < CreateFolder> < util:PermissionEx GenericRead =yesGenericExecute =yesUser =[SC_IUSR_USERNAME]Domain =[SC_IUSR_DOMAIN]/> < util:PermissionEx GenericRead =yesGenericExecute =yesGenericWrite =yesDelete =yesUser =[SC_ASPNET_USERNAME]Domain =[SC_ASPNET_DOMAIN]/> < / CreateFolder> < / Component> < / DirectoryRef> < / Fragment>

这似乎什么都不做。不为IIS_IUSRS帐户设置权限。我也从 trycatchfail

尝试了这个解决方案

<产品> <! - 为了简洁而删除了其余的产品代码 - > < Property Id =WEBUSERValue =Byah/> < Property Id =WEBDOMAINValue =Byah/> < CustomAction Id =SetWebuserIIS7Return =checkProperty =WEBUSERValue =IIS_IUSRS/> < CustomAction Id =SetWebuserIIS6Return =checkProperty =WEBUSERValue =IUSR_ [ComputerName]/> < CustomAction Id =SetDomainIIS7Return =checkProperty =WEBDOMAINValue =/> < CustomAction Id =SetDomainIIS6Return =checkProperty =WEBDOMAINValue =[ComputerName]/> < / Product> <片段> < DirectoryRef Id =UPLOAD> < Component Id =SetFolderPermissionsGuid =*> < CreateFolder> < util:PermissionEx User =NetworkServiceGenericAll =yes/> < util:PermissionEx User =AdministratorsGenericAll =yes/> < util:PermissionEx User =UsersGenericRead =yesGenericExecute =yes/> < util:PermissionEx User =[WEBUSER]Domain =[WEBDOMAIN]GenericAll =yes/> < / CreateFolder> < / Component> < / DirectoryRef> < / Fragment>

解决方案

这是一个简单的例子:

< DirectoryRef Id =WebsiteFolder> < Component DiskId =1Id =DummyComponentForPermissionsWebsiteGuid ={GUID-GOES-HERE}> < CreateFolder> < util:PermissionEx GenericRead =yesGenericExecute =yesUser =[SC_IUSR_USERNAME]Domain =[SC_IUSR_DOMAIN]/> < util:PermissionEx GenericRead =yesGenericExecute =yesGenericWrite =yesDelete =yesUser =[SC_ASPNET_USERNAME]Domain =[SC_ASPNET_DOMAIN]/> < / CreateFolder> < / Component> < / DirectoryRef>

这里有一个快速说明:

  • 上面的示例假设有一个< Directory> 与 Id =WebsiteFolder某处
  • 元素是< CreateFolder> 元素,因为此组件中没有其他元素。您可以轻松地将< util:PermissionEx> 元素添加到其他组件,其中包含文件,注册表值等。
  • 组件以上必须是功能的一部分,当然
  • 根WiX元素必须具有 xmlns:util =schemas.microsoft/wix / UtilExtension $ / $>
  • 在编译期间,您必须引用 WixUtilExtension

I'm creating an installer for an ASP.NET MVC web app using Wix, and I need to set a write permissions for the IIS_WPG on a particular folder in the site. I found an example (I think, still haven't got it working) of how to do this with cacls.exe:

<CustomAction Id="PermissionAppData" Directory="TARGETDIR" ExeCommand="&quot;[SystemFolder]cacls.exe&quot; &quot;[INSTALLDIR]\Content\uploads&quot; /T /E /G IIS_WPG:M" Return="check" />

However, I've heard that PermissionEx is better as it modifies ACLs instead of overwriting, (although the /E modifier here claims to do the same?) so I'd prefer to use that if possible. The only examples I can find for PermissionEx set permissions on the install dir and all subfolders - I don't want to do that.

How do I use PermissionEx to modify the permissions on a single folder within my install folder?

UPDATE

Ok, here's what I've got so far - based on Yan's answer below and a bunch of other examples online

My folder structure....

<Fragment> <!-- Will default to C:\ if that is the main disk--> <Property Id="ROOTDRIVE"><![CDATA[C:\]]></Property> <Directory Id="TARGETDIR" Name="SourceDir"> <!-- Will reference to C:\inetpub--> <Directory Id="INETPUB" Name="Inetpub"> <!-- Will reference to c:\Inetpub\wwwroot--> <Directory Id="WWWROOT" Name="wwwroot"> <!-- Will reference to c:\Inetpub\wwwroot\Demowebsite--> <Directory Id="INSTALLFOLDER" Name="DemoWebsite"> <Directory Id="CONTENT" Name="Content"> <Directory Id="UPLOAD" Name="upload"> </Directory> </Directory> </Directory> </Directory> </Directory> </Directory> </Fragment>

Yan's suggestion

<Fragment> <DirectoryRef Id="UPLOAD"> <Component Id="SetFolderPermissions" Guid="*"> <CreateFolder> <util:PermissionEx GenericRead="yes" GenericExecute="yes" User="[SC_IUSR_USERNAME]" Domain="[SC_IUSR_DOMAIN]"/> <util:PermissionEx GenericRead="yes" GenericExecute="yes" GenericWrite="yes" Delete="yes" User="[SC_ASPNET_USERNAME]" Domain="[SC_ASPNET_DOMAIN]"/> </CreateFolder> </Component> </DirectoryRef> </Fragment>

This seems to do nothing. Permissions are not set for the IIS_IUSRS account. I've also tried this solution from trycatchfail

<Product> <!-- rest of product code removed for brevity --> <Property Id="WEBUSER" Value="Byah" /> <Property Id="WEBDOMAIN" Value="Byah" /> <CustomAction Id="SetWebuserIIS7" Return="check" Property="WEBUSER" Value="IIS_IUSRS" /> <CustomAction Id="SetWebuserIIS6" Return="check" Property="WEBUSER" Value="IUSR_[ComputerName]" /> <CustomAction Id="SetDomainIIS7" Return="check" Property="WEBDOMAIN" Value="" /> <CustomAction Id="SetDomainIIS6" Return="check" Property="WEBDOMAIN" Value="[ComputerName]" /> </Product> <Fragment> <DirectoryRef Id="UPLOAD"> <Component Id="SetFolderPermissions" Guid="*"> <CreateFolder> <util:PermissionEx User="NetworkService" GenericAll="yes" /> <util:PermissionEx User="Administrators" GenericAll="yes" /> <util:PermissionEx User="Users" GenericRead="yes" GenericExecute="yes" /> <util:PermissionEx User="[WEBUSER]" Domain="[WEBDOMAIN]" GenericAll="yes" /> </CreateFolder> </Component> </DirectoryRef> </Fragment>

解决方案

Here is a plain sample:

<DirectoryRef Id="WebsiteFolder"> <Component DiskId="1" Id="DummyComponentForPermissionsWebsite" Guid="{GUID-GOES-HERE}"> <CreateFolder> <util:PermissionEx GenericRead="yes" GenericExecute="yes" User="[SC_IUSR_USERNAME]" Domain="[SC_IUSR_DOMAIN]"/> <util:PermissionEx GenericRead="yes" GenericExecute="yes" GenericWrite="yes" Delete="yes" User="[SC_ASPNET_USERNAME]" Domain="[SC_ASPNET_DOMAIN]"/> </CreateFolder> </Component> </DirectoryRef>

And here's a quick explanation:

  • The sample above assumes there a <Directory> with Id="WebsiteFolder" defined somewhere
  • The <CreateFolder> element is required because there's no other elements in this component. You can easily add <util:PermissionEx> elements to other components, which contain files, registry values, etc.
  • The component above must be a part of a feature, of course
  • The root WiX element must have xmlns:util="schemas.microsoft/wix/UtilExtension" namespace referenced
  • You must reference WixUtilExtension during compilation

更多推荐

Wix:使用permissionEx设置安装文件夹中的文件夹的权限

本文发布于:2023-11-12 11:49:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581423.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件夹   权限   文件   夹中   Wix

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!