Resolved Visual Studio Installer - how do I change folder perms?

Strahan

Member
Joined
Mar 28, 2015
Messages
11
Programming Experience
3-5
Hi. I installed the Vis Studio installer extension and make a VSI project. Everything works great. But I found that when I run my program it crashes:

C#:
Problem signature:
  Problem Event Name:    CLR20r3
  Problem Signature 01:    WallServer.exe
  Problem Signature 02:    1.3.4.0
  Problem Signature 03:    f8bc0692
  Problem Signature 04:    mscorlib
  Problem Signature 05:    4.8.4645.0
  Problem Signature 06:    648f6f00
  Problem Signature 07:    1695
  Problem Signature 08:    12e
  Problem Signature 09:    System.UnauthorizedAccess
  OS Version:    6.3.9600.2.0.0.272.7
  Locale ID:    1033
  Additional Information 1:    5861
  Additional Information 2:    5861822e1919d7c014bbb064c64908b2
  Additional Information 3:    9ce6
  Additional Information 4:    9ce6c0ff57baa798c7afdece9d025889

If I do cacls "c:\program files (x86)\my project folder" /e /g users:c /t then run the app, everything is peachy. So I figured no worries, I'll just have the installer set those perms on the folder when it's done. WHY. IS. THAT. SO. HARD?? lol I thought it would be a simple change. After reading a bunch of stuff, I ended up making a VBScript file to set the permissions and had a custom action to fire it as part of the install. Now when I install, I get a message saying the install failed because a script could not run. If I leave the error up, the files remain on the filesystem so I went to the app folder and double clicked the .vbs and it worked fine. I am getting the UAC popup during install, so it's running as admin.

Am I just going about it wrong? What is the right way to have a VSI project adjust the program application folder permissions when it's installing?

Thanks!
 
Don't do that.

It's so hard because you shouldn't be saving your program's data in the Program Folders directory. This was the first step that Microsoft took to try to patch all the big security holes in Windows. That was all the way back in Windows XP days that writing into Program Files was stopped unless you were running as administrator. In short change your program so that you don't write into the same directory where your program is installed. Instead write your code so that you write your data into either the Documents folder if your are writing out "documents" that the user will later use, or into the Program Data directory if it is data that is for the private use of your code that the user only indirectly interacts with.
 
If you really must change the permissions, and you are using Wix for your installer, just use the <Permission> tag like in this StackOverflow question:

Take time to consider the security implications of opening up the permissions to your program's installation directory, though.
 
As to saving in the program files, I agree, that's not idea. My program creates a folder in %appdata% and saves there. But for some reason, my program crashes with the info I posted prior if I run it w/o having perms over the folder. Not sure why.. oh God, I just realized the issue as I typed this. My config file saves in appdata, but the activity log still saves in the program folder (facepalm). I'll move that too.

Thanks!
 

Latest posts

Back
Top Bottom