I'm working with WPF project.I want to know can i give admin privileges to application folder when creating windows installer
2 Answers
Longer Writeup: System.UnauthorizedAccessException while running .exe under program files (several other options in addition to the ones listed below).
You can change the ACL for the installation folder making it writable for regular users, or you can use a manifest to require admin rights for your application to run (regular users generally can't elevate any applications like this - unless they enter an admin password). However it is very bad design to do so - to the level where your application could be rejected for use in certain environments.
A preferred approach could be to make sure you store the application files (data and settings) in locations writable for regular users outright - without any modifications or customizations in your setup. You could write to My Documents
or somewhere in %UserProfile%
- for example.
Please see this existing answer for a slightly more fleshed-out explanation: C++ MSI Package Administative Privileges.

- 39,960
- 25
- 91
- 164
You may need to clarify your question. There is some overlap here with Stein's answer, but to expand...
Folders do not get administrative privileges. Programs can get elevated privileges. Folders can have access rights that make them more (or less) accessible to programs with various privileges. Therefore:
If you want the installer to somehow enable your program to run as administrator (elevated), then the installer cannot do this. The program itself needs an elevation manifest which requests elevation to administrator privilege, which means that ordinary limited users cannot run it.
If the issue is that you have (or want to create) data files in the Program Files folder and your application cannot write to them when limited users run it, then the program is storing these files in the wrong location. Folders have names such as User's Application Data because that's what they are supposed to be used for. Changing the security of the Program Files folder containing your program code is generally considered insecure because limited users can then change your code files. The certification rules are a useful guideline:
"10.3 Your app data, which must be shared among users on the computer, should be stored within ProgramData
10.4 Your app’s data that is exclusive to a specific user and that is not to be shared with other users of the computer, must be stored in Users\\AppData"
You haven't said what tool you are using to create your MSI file, that might be useful to know if you have further questions.

- 20,260
- 1
- 18
- 28