How do I get WiX installer to request administrative privileges?

37,168

Solution 1

Answer on How to get WiX installer to request Administrative Privileges

Solution found by Opus Krokus in comment.

Answer

I added the following (to the Package element), and I am not sure which (or what combination) gave me what I need, but it works now: InstallPrivileges="elevated" AdminImage="yes" InstallScope="perMachine"

Solution 2

Look at the answer to this Stack Overflow question.

Here is the essence of the answer:

<Property Id="MSIUSEREALADMINDETECTION" Value="1" />

The solution suggested by Opus Krokus did not work for me.

Solution 3

You need 2 commands:

<Property Id="MSIUSEREALADMINDETECTION" Value="1" />     

<Condition Message="Installation requires Administrator privileges">
    <![CDATA[Privileged]]>
</Condition>

Observe that you must surround Privileged with <![CDATA[ and ]]>.

Share:
37,168

Related videos on Youtube

Opus Krokus
Author by

Opus Krokus

Updated on August 01, 2020

Comments

  • Opus Krokus
    Opus Krokus over 3 years

    We have a program we have developed in house. We are upgrading to use Visual Studio 2012, and so have to leave the Visual Studio installer project behind. InstallShield LE was giving us problems with shortcuts if the application was already installed. This left me with finally going with WiX.

    I have researched this for a few days and read several posts on how to get administrator rights, but none of them seem to work. The Package element has InstallPrivileges="1" and the following Property element is present:

    <Property Id="MSIUSEREALADMINDETECTION" Value="1" />
    

    It will not request administrator privileges when it starts, and so it fails when it tries to create the program folder in C:\Program Files(x86).

    • Natalie Carr
      Natalie Carr over 11 years
      MSI does not request admin rights until the InstallExecuteSequence. To get admin rights from the beginning you would have to use a bootstrapper, look at the Burn Engine provided with WIX.
    • Alexey Ivanov
      Alexey Ivanov over 11 years
      If your package installs per-machine, then MSI engine requests UAC elevation automatically. Could it be that your package is per-user but still tries to write to Program Files? Is ALLUSERS property set to 1?
    • Opus Krokus
      Opus Krokus over 11 years
      Thank you both for your suggestions. To Natalie: I cannot use a bootstrapper. The output MUST be an MSI (someone else hard coded the upgrade link into the current app). I added the following, and I am not sure which (or what combination) gave me what I need, but it works now: InstallPrivileges="elevated" AdminImage="yes" InstallScope="perMachine"
    • Ivan Vučica
      Ivan Vučica almost 11 years
      @OpusKrokus You can post that as the answer, and accept it. In fact, I highly recommend you do.
    • Mohammadreza
      Mohammadreza about 6 years
    • Mohammadreza
      Mohammadreza about 6 years
  • fjsj
    fjsj about 10 years
    I believe the right one is InstallPrivileges. I've removed the AdminImage attribute and my package is still requesting administrative privileges. AdminImage appears to mean another thing, see: stackoverflow.com/a/15434458/145349
  • Chaitanya Gadkari
    Chaitanya Gadkari about 8 years
    Is it possible in InstallScope="perUser" ? I can not set elevated privileges for per user.
  • Riz
    Riz over 5 years
    You will have to use InstallScope="perMachine" to make this work.