Hi All; I want to allow the user do a partial uninstall which would leave certain files and registry keys in place on the system. How can i keep a registry entry from being removed during the uninstallation process?

asked 15 Nov '11, 14:47

shawn's gravatar image

shawn
5668
accept rate: 0%

Could you provide more details on how you are doing a partial uninstall? Are you using multiple installers to deploy multiple elements of an application and want to behave differently based on if uninstaller is run standalone or as part of another uninstallation process? Are you using InstallBuilder 8 and add/remove components feature?

(16 Nov '11, 04:55) wojciechka ♦♦

Hi Wojciechka; What i have is a sinlge installer that, besides laying down our application also launches a Postgresql DB installer and inserts a version value under our registry. I want to offer the user the ability to completely remove our application or leave the DB and certain components resident on their system. so in the future if they want to reinstall it will be a shorter install and all their data will still be in place. I have this all set up, but the registry value is removed so when our app is reinstalled it doesn't see that the DB is still there and does a complete reinstall.

(16 Nov '11, 07:43) shawn

InstallBuilder removes the entire registry key for the product after uninstallation. However, you can re-create a registry key in Post-uninstallation actions, which are run after the key is removed.

For example you can register the key or keys both after installation and after uninstallation:

<postInstallationActionList>
    <registrySet>
        <key>HKEY_LOCAL_MACHINE\\SOFTWARE\\${project.vendor}\\${project.fullName}</key>
        <name>DBSetup</name>
        <type>REG_SZ</type>
        <value>1</value>
        <ruleList>
            <!-- ... -->
        </ruleList>
    </registrySet>
</postInstallationActionList>
<postUninstallationActionList>
    <registrySet>
        <key>HKEY_LOCAL_MACHINE\\SOFTWARE\\${project.vendor}\\${project.fullName}</key>
        <name>DBSetup</name>
        <type>REG_SZ</type>
        <value>1</value>
        <ruleList>
            <!-- ... -->
        </ruleList>
    </registrySet>
</postUninstallationActionList>

If the number of keys is very small, it may be easier to simply add the actions twice. If the number of keys is quite large, it is also possible to create a function that creates the registry keys - such as:

    <project>
    <!-- ... -->
    <functionDefinitionList>
        <actionDefinition>
            <name>createAdditionalRegistryKeys</name>
            <actionList>
                <registrySet>
                    <key>HKEY_LOCAL_MACHINE\\SOFTWARE\\${project.vendor}\\${project.fullName}</key>
                    <name>DBSetup</name>
                    <type>REG_DWORD</type>
                    <value>1</value>
                </registrySet>
                <registrySet>
                    <key>HKEY_LOCAL_MACHINE\\SOFTWARE\\${project.vendor}\\${project.fullName}</key>
                    <name>DBPath</name>
                    <type>REG_SZ</type>
                    <value>${dbpath}</value>
                </registrySet>
            </actionList>
            <parameterList>
                <stringParameter name="dbpath" default="" />
            </parameterList>
        </actionDefinition>
    </functionDefinitionList>
    <preInstallationActionList>
        <createAdditionalRegistryKeys>
            <dbpath>${installdir}/db</dbpath>
        </createAdditionalRegistryKeys>
    </preInstallationActionList>
    <postUninstallationActionList>
        <createAdditionalRegistryKeys>
            <dbpath>${installdir}/db</dbpath>
        </createAdditionalRegistryKeys>
    </postUninstallationActionList>
</project>

Please note that functions require passing parameters and have no access to variables - i.e. accessing ${installdir} directly would not work in a function, unless it is explicitly passed or <globalVariables names="installdir" /> action is used in the function to have it access variables from global scope.

link

answered 18 Nov '11, 05:47

wojciechka's gravatar image

wojciechka ♦♦
7.8k61122
accept rate: 26%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×54
×28
×13

Asked: 15 Nov '11, 14:47

Seen: 1,634 times

Last updated: 18 Nov '11, 05:47