melenaos
Posts: 1
Joined: Mon Sep 09, 2019 6:40 pm

Detect installation and trigger uninstall for specific setup

I have been delivered a project that uses Advanced Installer for it's setup.
I have the .aip file and I will attach it here if requested (just let me know if i need to hide some parts of the file).

My needs are that I want to run a registry query and see if the setup is installed on a machine and I want to been able to trigger a command to show the uninstall wizard.

As I can see there is no 'Uninstall.exe' next to the application in the program files folder but when I go to 'Add and remove programs' and press unistall frm the app then the uninstall wizard appears.
Catalin
Posts: 6601
Joined: Wed Jun 13, 2018 7:49 am

Re: Detect installation and trigger uninstall for specific setup

Hello and welcome to Advanced Installer forums,
I have the .aip file and I will attach it here if requested (just let me know if i need to hide some parts of the file).
There is no need for this, at least as for this moment.
My needs are that I want to run a registry query and see if the setup is installed on a machine
This can be achieved with our predefined support for searches. In order to create a registry search, you can proceed as it follows:

- go to "Search" page

- press the "New Search" button from the toolbar

- right click on the earlier created search --> "Add Search location" --> "Registry"

After doing so, you can configure the search to meet your requirements.

One thing to notice here is the fact that a search result is saved into a property. For instance, for a completely newly created search, its property will be named:

RESULT_PROPERTY

This property will store the value returned by the search. This can be further be used to condition a custom action, for instance, or anything that you need to be conditioned.

Now this:
and I want to been able to trigger a command to show the uninstall wizard.
can indeed be achieved by going to Control Panel and uninstalling your setup from there.

Similar to that, you can uninstall the program from a command prompt (e.g. WIN+R button --> cmd.exe --> Enter) by using a command line as it follows:

msiexec /x {path_to_your_package}

or

msiexec /x {package_product_code}

e.g.

msiexec /x "C:\MySetup.msi"

With that being said, you can create a small .BAT file having the above specified content (the uninstall command). This BAT file can be added as a temporary file in your project by going to "Files and Folders" page --> "Add Temporary Files" button from the toolbar.

After doing so, you can create a custom action which will call this .BAT file during the installation of your main package. To do so, you can go to "Custom Actions" page --> add a "LaunchFile" custom action with sequence (by pressing the "Add custom action with sequence" button which is placed to the right side of the custom action's name). After doing so, schedule this custom action after the "Paths Resolution" action group (in "Wizard Dialogs Stage"). In the "File to launch" field, press "[" and then, form the drop-down, select "File...". In the spawned dialog, select the earlier added temporary file.

The above step-by-step is exactly as you have asked (a search + custom action). However, please have a look on the below method which I find much easier to implement.

METHOD 2

Now, an easier method would be to use the "Upgrades" section from the "Upgrades" page. In this section you can specify other products that will be upgraded when your package will be installed. Note that these packages must be MSI-based, you cannot use this page to upgrade packages which don't use the Windows Installer technology.

Basically, if you know the product code of the product you want to uninstall, you can add it there and upon the installation of your main setup, that package will be uninstalled. For more information about this, please have a look on our "Upgrades Page" article.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”