0

In a Visual Studio (2013) Deployment Project, I have a resource file (a text-file called settings.cfg) that shall be copied to the application folder. The ReadOnly-Property of that file is set to False.

After installation on the target platform (Win 7 Pro), the file is present (in the application folder), but the file may not be modified by a user without Admin-Rights, it is read-only.

Obviously in the windows-explorer you can modify the access options in the properties dialog, but you need admin rights + time/effort.

Is there a way to allow modification of the file by any user right from Visual Studio?

Said
  • 3
  • 2

1 Answers1

2

Editorial answer: Don't install files in the Program Files folder if you want limited users to be able to update them. There are folders like User's Application Data Folder that are actually for the user's data.

The practical answer is that there is nothing built in to Visual Studio setups to do this, so that means writing custom action code to change the access rights. That's really a "how do I change access rights on a file" question rather than a question on setup projects. I suspect the code and setup changes to move that file to a location where it just works might be easier.

Lots of examples of custom actions here:

https://www.google.com/?gws_rd=ssl#q=visual+studio+custom+action+walkthrough

and this should help too:

https://www.simple-talk.com/dotnet/visual-studio/visual-studio-setup---projects-and-custom-actions/

PhilDW
  • 20,260
  • 1
  • 18
  • 28
  • It's not an issue of where the file is placed. The file shall not be user-specific but target-system-specific. Therefore I didn't use the user's appdata folder. Changing the file's location to the AppData folder or a custom folder doesn't change anything. But still from your answer it seems, you can'T do this from a vs setup project. So thanks anyway. – Said Mar 31 '15 at 13:09
  • What do you mean by custom action code by the way? Like a batch-script that must be run on installation? That would lead me to the question: Can you include a batch script in a setup project and run it from/by the installer? My guess would be no but I would happily be mistaken. – Said Mar 31 '15 at 13:16
  • Phil knows this but is too kind to say it.... writing custom actions to manipulate file ACL's is a horrible reinventing the wheel anti pattern. To do it in .BAT is just plain unprofessional. Take a look at another MSI authoring tool that actually exploses the underlying LockPermissions table to avoid these pitfalls. – Christopher Painter Apr 03 '15 at 02:26