How do I get WiX installer to request administrative privileges?
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 ]]>
.
Related videos on Youtube
Opus Krokus
Updated on August 01, 2020Comments
-
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 followingProperty
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 over 11 yearsMSI 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 over 11 yearsIf 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 over 11 yearsThank 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 almost 11 years@OpusKrokus You can post that as the answer, and accept it. In fact, I highly recommend you do.
-
Mohammadreza about 6 yearsPossible duplicate of WiX installer should always run as administrator
-
Mohammadreza about 6 yearsCheck this: WiX installer should always run as administrator
-
-
fjsj about 10 yearsI believe the right one is
InstallPrivileges
. I've removed theAdminImage
attribute and my package is still requesting administrative privileges.AdminImage
appears to mean another thing, see: stackoverflow.com/a/15434458/145349 -
Chaitanya Gadkari about 8 yearsIs it possible in
InstallScope="perUser"
? I can not set elevated privileges for per user. -
Riz over 5 yearsYou will have to use
InstallScope="perMachine"
to make this work.