Search code examples
c#installationwindows-installervisual-studio-2019

Why does installer fail after removing elevated privilege requirement?


I followed the instructions in this answer about making a setup.msi work for non-elevated users: https://stackoverflow.com/a/55700346/11860907

I have used these instructions for a different application with success.

When I run the .msi as it is, it requires admin permission to install but otherwise installs with no issue.

Here is the .bat file I ran to remove the admin permission prompt

"C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x86\MsiInfo.exe" "C:\Users\jbrown\source\repos\Step File Generator\Step File Tool\Release\Step File Tool.msi" -w 10
pause

After I ran this bat and tried to install the msi, it continued past the part that usually asks for admin permission but then why do I get the following error?

The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2920.

enter image description here

I researched this error code without helpful results. The following suggested I get an msi log: https://www.itninja.com/question/the-error-code-is-2920

When I try to run the msi through powershell with this command:

msiexec /l*v "H:\log.log" /i '.\Step File Tool.msi'

I get the following error:

This installation package could not be opened. Verify that the package exists and that you can access it, or contact the application vendor to verify that this is a valid Windows Installer package.

And the the following is the log output:

=== Verbose logging started: 12/11/2020  11:31:47  Build type: SHIP UNICODE 5.00.10011.00  Calling process: C:\WINDOWS\system32\msiexec.exe ===
MSI (c) (84:A0) [11:31:47:820]: Font created.  Charset: Req=0, Ret=0, Font: Req=MS Shell Dlg, Ret=MS Shell Dlg

MSI (c) (84:A0) [11:31:47:820]: Font created.  Charset: Req=0, Ret=0, Font: Req=MS Shell Dlg, Ret=MS Shell Dlg

MSI (c) (84:A0) [11:31:47:839]: Resetting cached policy values
MSI (c) (84:A0) [11:31:47:839]: Machine policy value 'Debug' is 0
MSI (c) (84:A0) [11:31:47:839]: ******* RunEngine:
           ******* Product: .\Step File Tool.msi
           ******* Action: 
           ******* CommandLine: **********
MSI (c) (84:A0) [11:31:47:841]: Machine policy value 'DisableUserInstalls' is 0
MSI (c) (84:A0) [11:31:47:884]: Note: 1: 1324 2: . 3: 1 
MSI (c) (84:A0) [11:31:47:884]: MainEngineThread is returning 2
=== Verbose logging stopped: 12/11/2020  11:31:47 ===

Solution

  • Limited Per-User Setups: Per user setups must adhere to a number of restrictions: https://www.advancedinstaller.com/user-guide/single-package.html

    I don't like per-user MSI installers and I find it hard to deliver setups that work properly for both per-machine and per-user deployment scenarios. It has to do with the above restrictions conspiring on you. I would select one or the other (per-machine or per-user only - some more complexities here with per-machine setups that can hide shortcuts from other users).

    Samples: Here are some per-user samples using WiX:

    The core of making a limited privilege setup is to adhere to the limitations listed in the link above, and - if you are using WiX - to set the Package element appropriately (for other tools you need to set these parameters in the appropriate GUI - Summary Information Stream settings in the MSI):

    <Package InstallerVersion="200" Compressed="yes" InstallScope="perUser" InstallPrivileges="limited" />
    

    MSI Tools: Visual Studio Installer projects have many limitations. Some reasons not to use them.