WiX Installer - Children of LocalAppDataFolder ins

2019-07-31 17:53发布

Brand new to WiX and I'm trying to fix a bug in some software I took over recently. As part of the product definition we have certain files being installed to the user's "AppData\Local" directory. The current project setup works fine when the user has install privileges, with the files being placed in the expected users "AppData\Local" directory.

However, if the UAC prompt pops up requiring admin credentials, the files end up being install in the admin account's "AppData\Local" directory instead.

In the product file we have something like:

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="LocalAppDataFolder">
    <Directory Id="MyData" Name="My Data">
      ...
    </Directory>
  </Directory>
</Directory>

And then in a heat.exe generated file I have

<Fragment>
  <DirectoryRef Id="MyData">
    <Directory Id="UserMaps" Name="User Maps" />
  </DirectoryRef>
</Fragment>
<Fragment>
  <ComponentGroup Id="User_Maps_Components">
    <Component Id="Map1.png" Directory="UserMaps" Guid="{C27...autogenerated}">
      <File Id="Map1.png" Source="$(var.MapPath)\Map1.png" KeyPath="no" />
      <RegistryValue KeyPath="yes" Root="HKCU" Key="Software\MyApp\Usermaps" Type="integer" Value="1" Name="Map1.png" />
    </Component>
  </ComponentGroup>
</Fragment>

Is there a way to ensure that the files will be installed to the initiating user's directories, rather than the admin's account?

We have files installing to "Program Files" as well, so I could always install the files there and copy them over as part of my applications initialization logic if they aren't found in the active user's folders, but was interested in seeing if there was a WiX specific way of doing things.

1条回答
家丑人穷心不美
2楼-- · 2019-07-31 18:12

I assume you are actually entering an admin password and specifying an admin account to run the setup with? That is as opposed to elevating the admin account you are logged in with. The latter should make the file install in the expected folder. The former would install like you describe.

I would roll with the approach you describe yourself: copy the file in place to each user profile from a copy installed per machine. I wrote up some suggestions for user profile and HKCU deployment a while back. Just some thoughts on the subject - a subject which seems to have few good answers. The Active Setup approach is apparently no longer supported in Windows 10.


Throwing in Some Links:

查看更多
登录 后发表回答