Visual Studio produced MSI Installers, Program Files, and Administrator Access
I have a working program that I am ready to generate an MSI from for distribution. The default install location is C / Program Files / Foo / Bar
, and that's where I'd prefer it install. However, after installing in that location, the program refuses to run unless right-clicked and "run as administrator".
I understand that the program requires administrator access because it is installed in C / Program Files
(I have an alternate install path that installs it to the desktop that lacks this problem), so I am looking for a way to not have to run the program as an administrator every single time I want to use it.
I had thought that installing the .msi "as administrator" would solve the problem, but right-clicking the .msi does not provide a "run as administrator" as I expected.
Is there any way to make it so I don't need to run the program as an administrator each time, while maintaini开发者_高级运维ng the c / program files
install directory?
Build the MSI with a setup.exe. You can then right click the EXE and run as Admin. You can't do this to the MSI because it isn't a program, it's a document ( database ) that's executed by a different program ( msiexec.exe ).
Usually this happens when the application tries to write data in a per-machine location (like Program Files or HKEY_LOCAL_MACHINE). In this case the application will work only if it's launched as an Administrator.
A solution is to use per-user locations for application data. For example Application Data (AppData) folder under the user profile folder and HKEY_CURRENT_USER.
However, if your application really needs Administrator privileges, you can use an UAC application manifest.
精彩评论