We have an Excel AddIn say A written in C#, Add-In Express. The installer is built from setup project in VS. Now we want to integrate it to another bigger add-in application say B. we want to be able to uninstall A during installation of B. B is also written in C#, but its installer is built from Advanced Installer.
I tried VBA like below, AddIns only contain "A XLL Add In" but not "A COM Add In". so it does not work. So I am thinking to write an exe to detect if A is installed and if so, uninstall it.
and call the exe in installer of B.
Anyone know how to "uninstall a program in C#" ? or there is better solutions? thanks
Once I can detect A and uninstall it in an exe, I will be able to hook it in installer of B.
Installer/Uninstaller class in .NET is not an option since I am not using them in installer of B.
Dim item As AddIn
Set item = Application.AddIns("A COM Add In")
If Not item Is Nothing Then
item.Installed = False
'item = Nothing 'Not sure if this does anything
End If
Dim item As AddIn
Set item = Application.AddIns("A XLL Add In")
If Not item Is Nothing Then
item.Installed = False
'item = Nothing 'Not sure if this does anything
End If
You can uninstall the previous version by invoking MSI directly:
msiexec /x YOUR-PRODUCT-CODE
Replace YOUR-PRODUCT-CODE
with the real product ID used in your MSI package which installed the AddIn A.
You may want to add /qn
option to completely suppress its UI.
MSI also provides API you can use to find out if the product is installed and to uninstall it.