Conditionally uninstall a file - Advanced Installer Community
tscheuerman
Posts: 43
Joined: Thu Feb 11, 2016 11:39 pm

Conditionally uninstall a file

Hello,

I was hoping you could provide some guidance on how I might conditionally uninstall a specific file. Let me explain my situation...

I have 3 Advanced Installer projects A, B, and C.

Advanced Installer project A - This project installs the primary software product.

Advanced Installer project B - This project installs an "Add On" project into the same location and project A. Project B is dependent on Project A being installed (this I have working correctly). Project B installs x.dll.

Advanced Installer project C - This project installs an another "Add On" project into the same location and project A. Project C is dependent on Project A being installed (this I have working correctly). Project C also installs x.dll.

1. The user runs Advanced Installer project A to install the primary software product.
2. The user runs Advanced Installer project B and C to install the "Add On" products. Both these products install and use the same dll (i.e. x.dll).

Now, the user uninstalls one of the "Add On" products (i.e. B). In doing so, x.dll is removed. This in turn break "Add On" product C.

Questions:
1. Does Advanced Installer provide functionality that would prevent this from occurring?
2. If NO to #1, then it would seem that I could handle this as a Custom Action called by both project B and C (in the Uninstall phase) that would only delete x.dll if the "other" dependent "Add On" product was not installed. This approach would required that I somehow mark x.dll to not be removed during an uninstall process so that my Custom Action could conditionally delete x.dll, is this possible?

Thanks in advanced

Todd
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Conditionally uninstall a file

Hi Todd,
1. The user runs Advanced Installer project A to install the primary software product.
For this, you can take advantage of the shared components mechanism. You can use the Organization page to share the component of the file between packages. The following conditions must be met:
  • the component uses the same name and same GUID in all packages
  • the file is installed in the same location by all packages (it is recommended to use a public location)
This way, Windows Installer will see the component as shared between packages and it will use a reference count for it. Installing a package with the shared component will increase the reference count and uninstalling one will decrease the reference count. The component is removed when the last package which contains it is uninstalled (the reference count reaches 0).

Please let me know if that helped.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”