Search code examples
c#windowsadmin-rights

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 maintaining the c / program files install directory?


Solution

  • 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 ).