简体   繁体   中英

Wix Burn: How to store the custom InstallFolder for later modifications?

I'm trying to solve this for a while now. I've authored a custom UI for my Bootstrapper Application. Setting a default value for InstallFolder is not the problem, but when the user changes this path, how can I store this path for later changes in add/remove programms, eg when another Package in the bundle should be installed by modifying the Bundle? To write in the Registry could be an option, but the Bootstrapper Application doesn't run elevated all the time, so that it can't write to HKLM. But there should be a way to do this, I saw similar things for Visual Studio...

You should be storing the InstallFolder value in the registry in one (or all depending on how it is authored) of your MSIs that are packaged with the bootstrapper application. On startup you can use a util:RegistrySearch to look for and set the InstallFolder in the bootstrapper.

<Fragment>      
    <util:RegistrySearch
        Id="ServerInstalledCheck"
        Root="HKLM"
        Key="SOFTWARE\$(var.OEMRegistryRootKeyName)\v7"
        Value="ServerPath"
        Result="value"
        Variable="ServerInstalled"/>
    <util:DirectorySearch
        Path='[ServerInstalled]'
        Variable='InstallFolder'
        After='ServerInstalledCheck'
        Condition='ServerInstalled' />
</Fragment>

I think you can directly set the variable InstallFolder in the registry search itself and omit the DirectorySearch. The DirectorySearch approach was used just to ensure we only set the InstallFolder to a location that actually exists on the machine. There may be other advantages as well but I can't think of them at the moment.

This will retain your default InstallFolder location on a fresh install and 'remember' the selected install location when running to uninstall/modify/upgrade.

You are right that you cannot rely on writing any registry keys inside your bootstrapper application because it is not guaranteed (and really shouldn't be) run elevated.


This is basically following the 'remember property' pattern which is explained here . Whenever you want to remember a value set in a previous install during modify/upgrade/removal, this is generally the go to.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM