Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Version number of the currently installed app


2 replies to this topic

rkode

rkode
  • Full Members
  • 20 posts

Posted 27 May 2008 - 20:27

Hello World,

InstallShield 2008 Professional.
Basic MSI with several InstallScript functions.

I have been asked to print, to a log, the version number of our application before I upgrade it to a newer version.

So, I'm trying to figure out how I can acquire the version number of an already installed version of our app.

The problem however, (at least for me) is that we change the product code each time we do a weekly build.

So, I can't go searching for a specific GUID.
(Cuz I can’t say with 100% certainly what the GUID will be.)

I tried doing an MsiGetProperty "ProductVersion", but that returns the version of what WILL be installed when the upgrade is completed, NOT the version of what is already on the pc.

I don't necessarily need to acquire the version number via InstallScript if there is some other way to acquire it.

I just need to get the version number of the already installed product into a property so that I can manipulate it (and then print it).


Any suggestions would be greatly appreciated.

Thanks in advance to everyone.


Ray in Wisconsin





Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 30 May 2008 - 12:18

The action property you specified in the Upgrade table should hold the ProductCode of the old version that is being removed by your Major Upgrade.

rkode

rkode
  • Full Members
  • 20 posts

Posted 19 June 2008 - 18:41

Hello again.
It has been some time sinse I asked for help on this issue.
Thanks to you Stefan, for your reply.
And thanks tp the good folks at InstallShield for their help as well.

In the event that anyone else might have the need to accomplish this same thing, I thought I would post how I managed it.

I'm far from an expert in these matters and the solution is not elegant.
But it DOES work.
My hope is that the following might make some elses life a bit earier.

Take care everyone.

Ray in Wisconsin


First:
My goal was, during an upgrade of my product, to acquire the version number of the currently installed version of my product.

We build our product, almost every day, and the product code changes.
So, I can't know, for sure, what the product code on the pc, might be.

I use InstallShield 2008 Professional.
And my installtion is a basic MSI.

Here's what I learned:

The FindRelatedProducts action saves the currently installed ProductCodes found on the system that the Upgrade will be applied to.
The RemoveExistingProducts performs the uninstall of the old version.

If you schedule a custom action in between these two events, you could use the ProductCode saved by FindRelatedProducts to search the registry for the version.

The registry entry to find is:
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\[Product Code]\DisplayVersion

The property containing the ProductCode is:
Under the Media/Upgrades view, create a Major Upgrade Item.
Go to the Major Upgrade item's Advanced tab.
Find the property labeled Detect Property.
The value of Detect Property is the name of the public property that will contain the currently installed version's ProductCode (This property usually defaults to ISACTIONPROP1).

To summarize:

Create a custom action that is scheduled After FindRelatedProducts but before RemoveExistingProducts.
In the custom action, use MsiGetProperty to retrieve the ProductCode from ISACTIONPROP1.
Use the RegDB functions to query the registry value of:
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\[Product Code]\DisplayVersion

Sooooooo,
I created a public property to hold the version number.
I named this property INSTALLEDPRODUCTVERSION.

I then wrote the following InstallScript function:

function RetrieveProductVersion(hMSI)

NUMBER nBufferSize, nvSize, nvType;
STRING szCurrentProductCode, szRegKey, szValueName, svValueData;

begin
try

// Retrieve the product code of the currently installed version of my product.
nBufferSize = MAX_PATH + 1;
MsiGetProperty (hMSI, "ISACTIONPROP1", szCurrentProductCode, nBufferSize);

// Build the variables necessary to retrieve the version number of the currently installed version of my product based on the product code obtained above.
nvType = REGDB_STRING;
szRegKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\";
szRegKey = szRegKey + szCurrentProductCode;
szValueName = "DisplayVersion";
nvType = REGDB_STRING;

// Retrieve the actual version number of the currently installed version based on the product code obtained above.
RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE);
RegDBGetKeyValueEx (szRegKey, szValueName, nvType, svValueData, nvSize);

// Now store the version number in the public property named INSTALLEDPRODUCTVERSION
MsiSetProperty (hMSI, "INSTALLEDPRODUCTVERSION", svValueData );

catch
endcatch;
return ERROR_SUCCESS;
end;

Then I created an InstallScript custom action that called the above InstallScript function.

Basically, that's it.
After the above was executed, INSTALLEDPRODUCTVERSION held the version number of the currently installed product.
IE: 08.020.001.