views:

789

answers:

1

I've already gone through:

http://stackoverflow.com/questions/211192/check-if-the-application-is-already-installed

http://stackoverflow.com/questions/488717/detecting-if-a-program-is-already-installed-with-nsis

http://nsis.sourceforge.net/Add_uninstall_information_to_Add/Remove_Programs

My questions are little more in depth and little more general.

So, as you understood my problem is that I want to check if "Certain Applications" are already installed on the user's machine? I'm generating the installer using Advanced Installer.

First few questions:

  • What is Upgrade Code? Advanced installer has option, Product Version (identify by Upgrade Code)
  • What is Product Code? Advanced installer Product Version (identify by Product Code)
  • Component is installed : GUID. What is GUID?

All the above three has values like this:

{49EB7A6A-1CEF-4A1E-9E89-B9A4993963E3} I don't know what these values are but it seems that computer is recognizing software using this kind of strange ID.

My required applications are

  1. MySQL DBMS
  2. MySQL .NET Connector

One fact that I discovered is Upgrade Code & Product Code can be extracted from its "msi installer". So, I extracted these values from the installers & registry.

MySQL Server

Installer = mysql-5.1.43-win32.msi 
Upgrade Code = {49EB7A6A-1CEF-4A1E-9E89-B9A4993963E3}
Product Code = {0ECED7D8-FF53-4DC9-958E-C2177F528DE4}
GUID (for component Installed) = ????
Uninstall Path = HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{0ECED7D8-FF53-4DC9-958E-C2177F528DE4}

Installer = mysql-5.1.46-win32.msi
Upgrade Code = {49EB7A6A-1CEF-4A1E-9E89-B9A4993963E3}
Product Code = {EA8FDE5A-2B33-4EDD-B7E7-8D179DF731A5}
GUID (for component Installed) = ????
Uninstall Path = HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{EA8FDE5A-2B33-4EDD-B7E7-8D179DF731A5}

Installer = mysql-essential-5.1.46-win32.msi
Upgrade Code = {49EB7A6A-1CEF-4A1E-9E89-B9A4993963E3}
Product Code = {AD33AF2C-6485-4106-B012-1D9CDC88A454}
GUID (for component Installed) = ????
Uninstall Path = HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{AD33AF2C-6485-4106-B012-1D9CDC88A454}

Installer = mysql-essential-5.0.89-win32.msi
Upgrade Code = {49EB7A6A-1CEF-4A1E-9E89-B9A4993963E3}
Product Code = {9A4DA7EF-A7B9-4282-90AD-10976AA24E69}
GUID (for component Installed) = ????
Uninstall Path = HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{9A4DA7EF-A7B9-4282-90AD-10976AA24E69}

Observation from above data:

  • UpgradeCode of a software is constant & is irrespective of its version. But surprisingly there is no single entry in the registry with the value of UpgradeCode
  • ProductCode is version specific & it is used by the MSI internally which is actually reasonable because. MSI allows applications of different versions to be installed side by side.
  • I don't know how to find GUID.

MySQL ADO .NET Driver

Installer = mysql.data.5.2.5.msi
Upgrade Code = --- 
Product Code = {5FD88490-011C-4DF1-B886-F298D955171B}
GUID (for component Installed) = ????

Installer = mysql.data.6.2.2.msi
Upgrade Code = ---
Product Code = {5FD88490-011C-4DF1-B886-F298D955171B}
GUID (for component Installed) = ????
UninstallPath =HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{5FD88490-011C-4DF1-B886-F298D955171B}
Installer =  mysql.data.6.2.3.msi
Upgrade Code = ---
Product Code = {5FD88490-011C-4DF1-B886-F298D955171B}
GUID (for component Installed) = ????

Observations from above data:

  • surprisingly, it couldn't find UpgradeCode from installer of mysql.data.*.msi. I wonder why? This contradicts with my above observation.
  • ProductCode for all different versions is same here. This again contradicts my above observations.
  • I still don't know how to find GUID.

Now,

  • What exactly are these ProductCode & UpgradeCode & GUID.
  • Which denotes what?
  • Why are above observations contradicting?
  • I don't care about versions. I don't want to depend on Application Name then how do I check if MySQL driver & MySQL ADO .NET.
  • Does detection become simple if they are .NET assemblies? How to do then? I don't want to ship the assemblies with my deployed files.
+2  A: 

UpgradeCode denotes a product with different versions.

ProductCode denotes a version of a product.

For example, theoretically there is one ProductCode for Microsoft Word 2003 and a different one for Word 2007. However both Word 2003 and 2007 would share the same UpgradeCode since you can upgrade from one to the other.

GUID simply means Globally Unique Identifier. It's a large string of numbers and letters that should be unique on the planet.

UpgradeCodes and ProductCodes are kept in the Registry, but they're hidden and encrypted and you'll need to use a tool to query them. For example:

MsiGetProductInfo(ProductCode, INSTALLPROPERTY_VERSIONSTRING, lpVerName, &cchVerName);
MsiEnumRelatedProducts(UpgradeCode, 0, 0, ProductCode);

To check and see if a product is already installed on a user's machine you might use MsiEnumRelatedProducts() as above. I think you're asking more than what can be answered in a StackOverflow answer. Consider studying more about MSI:

MSDN section on Windows Installer

William Leara