23

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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Opus Krokus
  • 241
  • 1
  • 2
  • 3
  • 6
    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. – Natalie Carr Jan 16 '13 at 09:26
  • 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? – Alexey Ivanov Jan 17 '13 at 07:27
  • 5
    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"` – Opus Krokus Jan 18 '13 at 21:56
  • 1
    @OpusKrokus You can post that as the answer, and accept it. In fact, I highly recommend you do. – Ivan Vučica May 10 '13 at 19:00
  • Possible duplicate of [WiX installer should always run as administrator](https://stackoverflow.com/questions/6122282/wix-installer-should-always-run-as-administrator) – Mohammadreza Apr 15 '18 at 11:15
  • Check this: [WiX installer should always run as administrator](https://stackoverflow.com/a/49841229/775110) – Mohammadreza Apr 15 '18 at 11:55

4 Answers4

30

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"

Community
  • 1
  • 1
Atrotygma
  • 1,133
  • 3
  • 17
  • 31
  • 5
    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: http://stackoverflow.com/a/15434458/145349 – fjsj Mar 18 '14 at 22:30
  • 2
    Is it possible in `InstallScope="perUser"` ? I can not set elevated privileges for per user. – Chaitanya Gadkari Jan 28 '16 at 10:11
  • 2
    You will have to use `InstallScope="perMachine"` to make this work. – Riz Dec 18 '18 at 07:45
0

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.

Community
  • 1
  • 1
Andreas
  • 659
  • 6
  • 17
0

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 ]]>.

Markus
  • 101
  • 6
-1

This is what worked for me, for my MSI created for installation on Windows 7 (and later versions):

  <!-- Set per-machine installation as default.
  See See http://msdn.microsoft.com/en-us/library/dd408007.aspx for an explanation of ALLUSERS=2 and MSIINSTALLPERUSER="".
  -->
  <Property Id="ALLUSERS" Value="2" />
  <!-- Needs to be empty value (and empty value must be commented out to get rid of error message when compiling):
  <Property Id="MSIINSTALLPERUSER" Value="" /> 
  -->

As mentioned in the above XML-comment, see http://msdn.microsoft.com/en-us/library/dd408007.aspx for details.

Eirik W
  • 3,086
  • 26
  • 29