15

I developed a custom installer with WiX for a .NET WPF application. It works fine if I right-click and run as administrator, however when running without, some components fail to install due to insufficient privileges.

The components include SQL Server Express 2008 R2, FoxIt Reader, an ActiveX component and some others. It also requires that some SQL scripts are ran on the newly installed database - anyway, they all require administrator privileges.


I tried adding the InstallScope="perMachine" and InstallPrivileges="elevated" attributes to the Package node, but this didn't seem to make a difference.

I'm sure it's something silly, but I couldn't find anything in the reference or online.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
rumblefx0
  • 642
  • 1
  • 9
  • 20

3 Answers3

24

I think if you just add

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

it should solve the problem. Let me know if not and I can do some more checking.

Christopher B. Adkins
  • 3,361
  • 2
  • 23
  • 27
  • Thanks - i'll fiddle around with it. Where exactly should i put this? – rumblefx0 May 27 '11 at 10:05
  • It goes anywhere under the Product element. I like to keep all my properties grouped at the bottom, but that is just personal preference. – Christopher B. Adkins May 28 '11 at 14:13
  • Thanks...this helped me with the same issue. – Brandon Sep 20 '11 at 22:31
  • 1
    Did not work for me. I need installscope as per user only, and need elevated installer as some files are copied in systems machine scope folders. I can run using command for this but i need it to prompt uac dialog on launch – Chaitanya Gadkari Jan 28 '16 at 10:08
  • Thanks for the answer, do you know why this is needed? – markmnl May 23 '16 at 02:08
  • In my case, adding this tag yielded a .MSI asking for elevation if double-clicked, but then if I click Yes on the UAC Window the .MSI seems to run without actual Administrator privileges. I.e. it doesn't install the program, while right-click -> Run as Administrator gets the program installed just fine. Weird... – Fry Simpson Nov 10 '20 at 17:43
2

Add this to your package element

<Property Id="ALLUSERS" Value="1" />    <!--equals to install="permachine" at package element but this element depricated -->
<Property Id="MSIUSEREALADMINDETECTION" Value="1" /> 

<Condition Message="Please Run as Administrator.">
      Privileged
</Condition>

Then creating a simple sfx archive file for msi file with Winrar and these options:

  • Setup tab > Run after execution input: your msi file name

  • Advanced tab > Mark Request Administrative access option checkbox

Mohammadreza
  • 2,913
  • 8
  • 31
  • 51
1

For me I was supposed to run a registry command to delete a system environment variable via the CustomAction WiX element, which required administrator privileges.

Using CustomAction → Impersonate="no" worked for me as mentioned in post https://stackoverflow.com/a/8657472/3205679.

WiX Custom Action code:

<CustomAction Id = "Uninstall_MYSYSENV"
              Directory  = "INSTALLFOLDER"
              ExeCommand = 'cmd.exe /c &quot;reg delete       "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session    Manager\Environment" /v MYSYSENV /f&quot;'
              Execute    = "deferred"
              Impersonate= "no"
              Return     = "asyncNoWait"
              />

<InstallExecuteSequence>
      <Custom Action="Uninstall_MYSYSENV"
              After="InstallInitialize">Installed AND NOT UPGRADINGPRODUCTCODE</Custom>
</InstallExecuteSequence>
Community
  • 1
  • 1
SrikanthS
  • 66
  • 5