-1

I am attempting to make sure certain software does not exist before installing the newer version. Long story short, vendor requires me to do so, and although they recommend me to repair after install, that causes other issues such as undesirable restart (trust me I tried /norestart and I have even tried to modify the stored msi package to make sure it does not restart) but over all it just gives us soo much headache without the result we want.

So I tried to simply uninstall this software ahead of installing their newer one since that seem to have higher success rate without unnecessary issues.

Now I am accomplishing this by running batch file via ExePackage (with WiX toolset) with Vital="no". I have to do Vital="no" because when the older installer does not exist and if I call msiexec /x, it returns the error stating

this action is only valid for products that are currently installed

When the older installation exists, it works fine, but when it does not it errors out.

Now Vital="no" works fine, but I would prefer to suppress the error with msiexec /x if I can.

Is there any known way to solve this?

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
Shintaro Takechi
  • 1,215
  • 1
  • 17
  • 39

2 Answers2

1

In order to solve this problem, I checked the uninstall keys and only called msiexec /x on products that were listed. Though in my own case, we were switching installer tech (too many MSI bugs...) and were uninstalling older versions of our own.

Joshua
  • 40,822
  • 8
  • 72
  • 132
1

Installation State: You can use VBScript to check for the installation state of a product if you know its product GUID (replace the sample GUID here):

Dim installer : Set installer = CreateObject("WindowsInstaller.Installer")
MsgBox installer.ProductState("{6C961B30-A670-8A05-3BFE-3947E84DD4E4}")

There are a number of possible installation states. Here is a more comprehensive script to check product installation state. Check section 7 here.

Major Upgrades: I assume you are aware of how major upgrades work? (uninstall of existing installation and install of newer version with options for what order this happens in). They can in reality uninstall any other MSI package on installation via settings in its Upgrade table. This includes even competitive products (a bit mad one would have to say). You can - however - not install them again easily from within MSI for a number of technical issues. You could install them via a Burn setup.exe bootstrapper (which I think you use).

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
  • Hi Stein, unfortunately, Major Upgrade is not an option. Just by Major Upgrading (from SP19 to SP26 in this case), quoting from their wiki "If end-user use in-place upgrading from SP25 or previous version, after upgrading, they must repair the installation in Control Panel/Programs. Otherwise the ADO.Net database connection will NOT work." This required us to repair on the go, but that was giving us way too much support call, so I decided to uninstall them. – Shintaro Takechi Nov 09 '20 at 22:05
  • This is Crystal Reports? Sometimes you can just uninstall them early with major upgrades in order to clean up well and re-install, but there are exceptions (downgraded files for example and other quirks). – Stein Åsmul Nov 10 '20 at 00:44
  • Yea uninstall and then upgrade works better. Just have to know the guid for all the individual versions. However, they do not distribute the older versions of installer, so I could only support SP10 and SP19, but at least that is covered so that is good. – Shintaro Takechi Nov 10 '20 at 00:46
  • 1
    Check if they share the same upgrade code? You can then identify them as "related products" and uninstall them all one by one? See these answers: [Uninstall approches](https://stackoverflow.com/a/51412022/129130), [Uninstall with Powershell](https://stackoverflow.com/a/49077469/129130) (you call `installer.RelatedProducts` which yields a list of product codes that are related). – Stein Åsmul Nov 10 '20 at 00:51
  • Good choice. But wouldn't it give the capability of uninstalling the future version if user has them? Since Product GUID for the future version does not exist yet (but assuming Upgrade GUID is same), I would probably want to avoid that. And since Product code is unknown, I cannot reference the registry for the version number. – Shintaro Takechi Nov 10 '20 at 01:03
  • By means of the upgrade code - if it remains stable (which it often does) - you can detect any future product code for uninstall. It all depends on their release-design. You simply say "enumerate all related product codes sharing this upgrade code" (now and in the future). Upgrade code is intended to identify a "family of products" - for example different versions of the same product. They often can identify different language versions of the same product as well, but sometimes they have different upgrade code. By-design issue. – Stein Åsmul Nov 10 '20 at 01:54