Search code examples
installationwixwix3.5vdproj

Wix installed files elevate permissions


I have a WiX project, and it installs some executables and libraries on a folder located at ProgramFiles.

The problem comes when running one of these executables. Some of them need to be executed as Administrator to do all the tasks it should do. If I right click on it, and run it as administrator, it works well. But I want WiX to elevate that permissions for my files by itself.

Is there any way?

I tried doing this:

<Package Id="$(var.GUID_Package)"
         InstallPrivileges="elevated"
         InstallScope="perMachine" ...>

And:

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

But these two options only work for the .msi package (not for the installed files).

NOTE: I think I didn't explain myself correctly... My problems came on permissions with my installed files. I couldn't execute them correctly because of permissions. When I run them as administrator, obviously, all permissions are correct for execution. So what I had to do was change that permissions for each file I had trouble with.


Solution

  • For those who might be interested, I found a solution.

    At first, I added at my .wxs project a reference to WixUtilExtension, that you can find at the WiX folder.

    You can also add it as an external reference like this:

    xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
    

    After that, I could use locally PermissionEx:

       <File Id="$(var.productFamily)$(var.productSummary)"
          Name="$(var.productFamily)$(var.productSummary).exe"
          DiskId="1" KeyPath="yes"
          Source="$(var.release)$(var.productFamily)$(var.productSummary).exe" >
          <util:PermissionEx User="Everyone" GenericAll="yes" ChangePermission="yes" />
      </File>
    

    And with that I could elevate their permissions.