darbid
darbid

Reputation: 2721

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

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>

Upvotes: 0

Views: 2496

Answers (1)

Tom Blodget
Tom Blodget

Reputation: 20772

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.

Upvotes: 1

Related Questions