Mike-Ward.Net

Setting File Permissions in Wix 3.0

I’m new to Wix and to Windows Installers in general so some of this is likely wrong or obvious. Still, I couldn’t find much information on how to do set file permissions for a particular user account so I thought I’d share.

I needed my installer to set the folder permissions for the App_Data folder in an ASP.NET site. Typically, you need to give the “Network Services” account write permissions to this folder. I scoured the Internet for a solution and posted a question on Stack Overflow before coming up with my own solution.

<CustomAction Id="PermissionAppData" Directory="TARGETDIR"   
  ExeCommand="&quot;[SystemFolder]cacls.exe&quot;   
  &quot;[INSTALLDIR]\App_Data&quot;  
  /T /E /G &quot;NT AUTHORITY\Network Service:C&quot;" Return="check" />

Add this custom action to the install sequence table and you’re golden.

There’s a util:PermissionEx custom action in Wix 3 but it seems to only work for “well known” accounts (like Administrators). Maybe there’s a better way but darn if I could come up with it. Feedback appreciated.

← newer older →
.Net, Technology, Life, Whatever

Recent Posts

Checklist Buddy Available for Testing
Tweetz 2.0.0 Released
Tweetz 2.0 Beta
VSColorOutput 2.7 - Time Stamps
Fixed Focal-Length Eyeglasses, a Programmer's Best Friend
How to Choose the Right VPN Service
Two Handy Command Line Scripts
More... (1089)

Donate