Wix Toolset - Setting a Property to User Profile Folder path and Program Files

房东的猫 提交于 2020-01-06 07:29:11

问题


I am using Properties to set the values of Registry entries. This is so that on install the first time I have a default value and then on upgrade the current registry value is used.

I need to have a property that sets the path to the user's local folder and to the programs folder. I know the below code is wrong but how do I do it. I think at least I want to do a Type 51 custom action but don't understand the documentation.

I believe there are three relevant parts

<InstallExecuteSequence>
    <Custom Action="SetUserFolder" Before="InstallInitialize"/>
    <Custom Action="SetInstallFolder" Before="InstallInitialize"/>
</InstallExecuteSequence>

Custom Action

<CustomAction Id="SetUserFolder" Property="UserFolder" Value="[%USERPROFILE]" />
<CustomAction Id="SetInstallFolder" Property="P_InstallFolder" Value="[%PROGRAMFILES]" />

The property.

<Property Id="P_MyAPPPATH" Value="[P_InstallFolder]MyApp\">
    <RegistrySearch Id="S_MyAppPath" Type="raw" Root="HKCU" Key="Software\MyApp\Settings" Name="MyAppPath"/>
</Property>
<Property Id="P_MyAPPDB" Value="[UserFolder]\MyApp\MyAppData\">
    <RegistrySearch Id="S_MyAPPDB" Type="raw" Root="HKCU" Key="Software\MyApp\Settings" Name="MyAppdb"/>
</Property>

回答1:


As an alternative to using the properties you're defining, you might be able to use some built-in properties to better effect.

Instead of %USERPROFILE, consider LocalAppDataFolder. This will avoid your data from being copied between machines as a user roams between machines on a network domain. I'm guessing you don't need that but, if you do, use AppDataFolder and beware of the latencies involved.

Instead of %PROGRAMFILES, consider ProgramFilesFolder. This seems to be what you intend.



来源:https://stackoverflow.com/questions/17500373/wix-toolset-setting-a-property-to-user-profile-folder-path-and-program-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!