Visual Studio Setup Project - System and User Installer in same MSI-File

1.6k views Asked by At

I'm using Microsoft Visual Studio 2019 and Microsoft Visual Studio Installer Projects V1.0.2.

I'm aware how to generate a system wide installer:

  • InstallAllUsers property of the setup project is set to true.
  • InstallAllUserVisible property of the Installation Folder user interface is set to false.
  • The DefaultLocation of the Application Folder is set to [ProgramFilesFolder][Manufacturer]\[ProductName].

and I'm as well aware how to generate a user installer where no admin elevation is needed:

  • InstallAllUsers property of the setup project is set to false.
  • InstallAllUserVisible property of the Installation Folder user interface is set to false.
  • The DefaultLocation of the Application Folder is set to [LocalAppDataFolder]\Programs\[Manufacturer]\[ProductName].
  • PostBuildEvent: "%ProgramFiles%\Windows Kits\10\bin\x86\MsiInfo.exe" "$(BuiltOuputPath)" /w 10

See https://stackoverflow.com/a/55700346/7556646 and https://superuser.com/a/1633474/738960.

Now I'm asking myself the following questions:

  1. is the possibility to have the system installer and the user installer in the same msi-file and in the same setup project?

  2. Is it possible that the DefaultLocation of the Application Folder is set based on the InstallAllUsers property? The InstallAllUsers property can be changed in the Installation Folder user interface when the InstallAllUserVisible property is set to true.

  3. Would the above post build event a problem for system wide install?

1

There are 1 answers

1
Doug On
  1. Yes, in fact that is the normal way to build an MSI package so that the system administrator can choose what type of installation is appropriate for their environment. During the initial UI phase of the installer, or by properties on an unattended installation, the administrator will pick if they want a "Only Me" or a "All Users" installation. Although rarely used there are other installation options like network based administrative installation point installations that an admin may like to also see you supporting.

  2. Yes, but don't do that. The target folder should be set by command line or by the UI, not by your package. Refer to the TARGETDIR property documentation for more detail. By default Windows Installer will construct a suitable location from properties already present in your package.

Note that the value of the TARGETDIR property is typically set at the command line or through a user interface. Setting TARGETDIR by authoring a path into the Property table is not recommended because computers differ in the set up of the local drive.

  1. No, you've done this correctly if you are intending to set a preference for per-user installation. Typically you would present a UI dialog to choose the installation type, this then sets the ALLUSERS property for the execute phase of the installation. Admins are very familiar with just setting ALLUSERS themselves to pick what type of installation they want. By doing this for them in the build you are making a per-user installation the default and masking that a All Users installation is (presumably) supported through the command line. The documentation has additional info on steps required to suppress the UAC prompt, enhancing the per-user installation experience.

To suppress the display of the UAC dialog box when installing the application, the >author of the package should do the following:

Install the application using Window Installer 4.0 or later on Windows Vista. Do not depend on using elevated system privileges to install the application on the >computer.

Install the application in the per-user context and make this the default >installation context of the package. If the ALLUSERS property is not set, the >installer installs the package in the per-user context. If you do not include the >ALLUSERS property in the Property table, the installer does not set this property >and so per-user installation becomes the default installation context. You can >override this default by setting the ALLUSERS property on the command line. Set Bit 3 in the Word Count Summary property to indicate that elevated privileges >are not required to install the application.