1

I have a product that is installed across many sites. Now we have released a Upgrade. But the issue was that in the first version the installation was per user and now we have made it per machine installation. There are custom actions in the new version (v3) that run when the old installation (v2) is detected. But it is not being detected as installed when the msi is run as a different user that installed version 2. Is there a way to detect if the Old version is installed (even if it was installed by a different user than the current user), probably in install script.

Ajay Bhasy
  • 1,920
  • 1
  • 26
  • 38
  • Are there any shared places that you placed down some artifact (either a file or a registry key), or are you relying on keys laid down by the setup itself? Also, please disambiguate whether each version is an InstallScript or InstallScript MSI setup. – Michael Urman Sep 09 '15 at 12:02
  • can I tweak the installer so that the msi detects that the old version is already installed and runs as an update – Ajay Bhasy Sep 10 '15 at 11:56

2 Answers2

2

Check both registry 64/32 for installed applications. Look for your product GUID under those keys. If it's there, it's installed.

This works for MSI installed stuff.

32 Bit: [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall]

64Bit: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall]

  • In the install script I can read this value. But is there any way to make the msi automatically run as an upgrade by detecting the older version even for other users – Ajay Bhasy Sep 10 '15 at 11:57
  • You must configure your MSI installer to update properly. This needs to be authored in the Media->Upgrades node of the tree on the left of InstallShield IDE. There you can specify what versions to upgrade. – Peter Martin Oct 05 '17 at 13:57
1

Since you don't know how many users there might be on a machine and who installed your product as per machine or per user, I think the only thorough way is to use MsiGetProductInfoEx() or equivalent to search for your product for all users of the machine. For example, I don't know your exact scenarios, but if an administrator is installing your new per machine product on behalf of a user who installed it per user then you're stuck unless you can find out the user who actually installed it. It's no good looking for a per user administrator install! You'd need to enumerate all the users, get each SID and ask if it installed your product, using that API (or equivalent). If found, you'd tell the user to log on as that user and uninstall the product. IIRC it doesn't always succeed when another user (even admin) tries to uninstall a per user product installed by another user.

It's my experience that in most cases people try to detect if the product is already installed using some detection method that's independent of install context. Then, if your per machine major upgrade doesn't set the property that says it found a per machine install just throw an error and ask for a manual uninstall.

NB: Added Custom actions and Used ::MsiConfigureProduct() To uninstall and MsiGetProductInfoEx() to check the product is installed

Ajay Bhasy
  • 1,920
  • 1
  • 26
  • 38
PhilDW
  • 20,260
  • 1
  • 18
  • 28
  • By looking into many other questions like this one http://stackoverflow.com/questions/15652821/how-to-change-from-per-user-to-all-user-installation I came to know that there is no way to make this to work as an upgrade, So I had to go with a manual override. – Ajay Bhasy Sep 17 '15 at 12:06
  • I have made an edit can u explain a little about using API to achieve my scenario, ie uninstall old version if already installed for any user and then continue with normal install – Ajay Bhasy Sep 17 '15 at 12:13