how to install files even though user clicks NO in

2020-05-06 16:45发布

问题:

I have created a msi using Visual Studio Installer Projects. When i run the msi, uac prompt always appears in all machines. This is fine.

But for standard users, uac askes for admin username and password. Since standard users may not know admin passwords, hence they will not be able to install msi unless they get a person with admin credentials.

What i want is if user does not know admin password, then he can click NO in uac, but instead of msi installation failing, it should proceed installation. The custom actions which do not need admin privilege can succeed, and only the custom actions which needs admin privilege will fail. And of course, files should be installed.

回答1:

To avoid the UAC window, your installer shouldn't do anything that is require elevated permissions (e. g. install files to Program Files sub-folders or writing to registry in HKLM sub keys). And you should specify this before the Windows Installer will go to the installation stage and show you the UAC window.

You'll need to make separate features for each configuration and switch them according to some conditions. For example, you could ask a user about which kind of installation he/she wants to perform or check if the user is an admin. According to this you should switch on/off the corresponding features in your MSI.



回答2:

Settings: At least the below settings must be enforced in a per-user package. In WiX you have several constructs to help you with this, but I am not sure what Visual Studio Installer projects have. I do not like Visual Studio installer projects because of a number of severe technological limitations. Maybe consider using another tool? List of Deployment Tools, WiX Quick Start Tips.

Property Table: In the Property Table, set the following properties:

  • ALLUSERS=2
  • MSIINSTALLPERUSER=1

Summary Information: In Orca, go View => Summary Information... => Check the UAC Compliant box. Then test on a virtual. Also test whilst actually logged in as a standard user (obviously). There seems to be a property called MSIDEPLOYMENTCOMPLIANT that can be set to 1 to do this as well. I have never tested it. Will do soon.

Orca: I would try that first. Use Orca or an equivalent tool (towards bottom, prefer Orca over SuperOrca). If you have Visual Studio installed you have the Orca installer in the SDK folders. Try searching for Orca-x86_en-us.msi - under Program Files (x86).

(Currently the path is: C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86 - just replace the version numbers as appropriately and you should find the MSI quicker).


Some Links: Please read these two MSI SDK links:

  • Single Package Authoring
  • Installation Context
  • https://www.joyofsetup.com/2008/04/01/new-wix-feature-setting-package-installation-scope/