Question

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.

Was it helpful?

Solution 3

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.

OTHER TIPS

This can't be fixed by anything you do in the installer.

If the exe is doing one-time setup, e.g. Modifying files/folders in the Prog files directory, consider moving that into the wix installer.

If it is something that is happening on every run, you will need to identify what it is doing and try and change so that it does it in a way that doesn't require elevation. If it's not possible you will be stuck with having to elevate I'm afraid. The only other way to help this is to set the local machine policy to automatically elevate for administrators.

You can go with option of converting your msi to exe and when user executes exe, it will prompt user to run as administrator.

I am using dontnetinstaller for same and it works perfect.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top