Reputation: 8288
I've created an application that installs via MSI with version number X.X.X - lets say 1.0.0. Next, we created a custom self update process that uses no form of MSI. (We are replacing files via code.) This custom self update process is required and enables us to manage a large number of users remotely and quickly. We've had this running for a while now. The one thing that is bugging me is that the Version displayed on the Programs and Features screen for our application is still 1.0.0. Is there a way to update the program version from the main executable?
Upvotes: 0
Views: 2211
Reputation: 55571
You are trying to reinvent patching. Windows Installer doesn't support this and there's no way to do what you are trying to do.
Update: Tao of the Windows Installer, Part 2
Rule 21: Avoid Using Configuration Data You Don’t Own
As part of the initial design for the Installer, the consistency of installations was achieved via Microsoft taking ownership of the code for the install engine. This includes the location and format of all configuration data. This data is managed by the Installer and direct access by users or applications is discouraged; in fact some of the data is encoded to make it very difficult to manipulate manually.
You should not try to peek directly into Windows Installer configuration information. Instead, use the Windows Installer API to get the information you need. Accessing the data this way ensures that your package or application will continue to work even if the underlying configuration data changes location or format.
In this case the API is MsiGetProductInfo function. This function returns INSTALLPROPERTY_VERSIONSTRING
which is which is the ProductVersion property. This API has no mechanism to set the ProductVerion because MSI does this internally during PublishProduct Action. If you look in the registry you'll find it under HKCR\Installer\Products\PackedGuid\Version. The Packed Guid is a "Darwin transform" of your ProductCode in DWORD format. ProductVersion is stored in DWORD format with 1 byte for Major 1 byte for Minor and 2 bytes for build. This is because ProductVersion ignores the 4th field although it is stored in ARP.
This registry structure is obfusacated in an attempt to encourage rule 21. Don't mess with Windows Installer configuration data out of process. Let MSI handle it.
Upvotes: 1
Reputation: 3674
Changing from comment to answer for better readability, and discussion of facts to your question and concerning environment:
First let's see about your proposal of changing the value of DisplayVersion
in
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{MSI ProductCode}
for 32 bit MSI setups (most setups operate still here, often even if containing 64-bit or independent (e.g. .NET) code, but that is another matter) or
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{MSI ProductCode}
for 64 bit MSI setups. First, this is only the place for machine-wide ("LOCAL_MACHINE") setups, not for user-dependent setups, but that's ok, as this is standard.
It is not best practice to edit DisplayVersion. At least, it can be subject to discussions, if to edit it. In fact, it is a free string, and a number of setups out there are using this, calling their version not "1.0", but "V1.0" or "1.0a" or similar. If doing this, it is the less worst to do it in a custom action in the msi itself (at the very end).
At least, as an argument against those who call changing this key forbidden: This is not the place on which the MSI logically operates with versions, this version is not used for version compares. In fact it is just an output string.
OTOH, it can be overridden again by an original setup (MSI) repair/update/reinstall. So warning NOT to change manually has a background.
Additionally: There are Windows versions, especially older ones, who have update problems, so changing registry value does not immediately reflect the control panel view. There is an ARP cache for example holding all the install entries. I would not expect Windows 7 or higher to have these problems, but having seen problems in the past and knowing the ARP cache still exists is making me cautious here.
What I recommend, and I would call it good practice, is to not change this number, but let belong it to native MSI.
Instad make MSI setups invisble for users in control panel ("Programs and Features" or ARP how we still call it in the MSI and setup community because of it's older name):
Either set the ARPSYSTEMCOMPONENT
property in your MSI fix to 1 (normally hex 1, but because it's you, you can only choose decimal 1 :-)).
Or provide ARPSYSTEMCOMPONENT=1
as a command line parameter to any MSI setup you want, while installing.
In fact this is what Microsoft is doing with SQL server, Visual Studio, Office setups too. They consist of multiple setups which shall behave like invisible (setup) components.
Alternatively you can make (any) MSI setup "invisible" after install: By simply changing the registry value SystemComponent
(or adding) in the registry directly to 1 .
But this is not clean, again, because a repair or update or reinstall could change this again. But it would not break anything- at worst invisible setups would become visible.
Then you build another setup (maybe "main" setup) for the visual ARP settings or you just create a complete MSI independent key in the registry under the "Uninstall" key mentioned above. (Either in a program or in the "normal" MSI setup). This can be a GUID or a normal name. Look in your registry and you find a number of examples there for non-GUIDs, e.g. by Adobe, etc. Every non-GUID is not a "Windows Installer" (MSI) setup, but of course also some GUID-like-entries can be by non-MSI setups.
The main advantage is: This new DisplayVersion
in the MSI-independent key can be controlled by your own.
Upvotes: 1
Reputation: 8288
The MSI Installed version can be updated by modifying the registry value for the installed application located in one of two places. On my Windows 8 PC, it is located at the following:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{MSI-GUID}
It may also be located at:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{MSI-GUID}
To update the version number shown on the Programs and Features screen, modify the registry value "DisplayVersion"
Upvotes: -1