然而,我听说过 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=""[SystemFolder]cacls.exe" "[INSTALLDIR]\Content\uploads" /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?
UPDATEOk, 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设置安装文件夹中的文件夹的权限
发布评论