How can I perform a silent uninstallation as part of the upgrade process on Windows?

asked 13 Sep '11, 06:50

Jake's gravatar image

Jake ♦♦
796222226235
accept rate: 98%


You can retrieve the path to the uninstaller from the Windows registry and storing it in an installer variable.

<!-- In particular, this "${product_fullname} ${product_version}" string will make the installer detect its own previous installation. You will need to change it to match with the program and version you want to uninstall. -->

<registryGetMatch>
    <key>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${product_fullname} ${product_version}</key>
    <name>UninstallString</name>
    <variable>uninstaller_path</variable>
</registryGetMatch>

Then, you can execute the path stored in ${uninstaller_path}, in case it exists:

<!-- run the uninstaller program only if ${uninstaller_path} points to an existing file -->

<runProgram>

    <program>${uninstaller_path}</program>
    <programArguments>--mode unattended</programArguments>

    <ruleList>

        <fileTest>

            <path>${uninstaller_path}</path>

            <condition>exists</condition>

        </fileTest>

    </ruleList>

</runProgram>

Similar solutions can be applied to detect a previous installation directory as well.

link

answered 13 Sep '11, 06:51

Jake's gravatar image

Jake ♦♦
796222226235
accept rate: 98%

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:

×176
×40
×22
×14

Asked: 13 Sep '11, 06:50

Seen: 2,449 times

Last updated: 15 Sep '11, 06:51