问题
This problem, in fact, is to avoid a problem I will not solve
When I install my product once and I use the MSI again, the unloading process is performed. However, this does not remove residual information from the registry, which must be cleaned Up using "Windows Installer Clean Up", and when reinstalled, a registry permission issue occurs.
I saw the Checking for Oldies, However, it was found that FindRelatedProducts only performed on the first installation, that is, when I installed the MSI again, FindRelatedProducts did not.
<Upgrade Id='YOURGUID-7349-453F-94F6-BCB5110BA4FD'>
<UpgradeVersion OnlyDetect='yes' Property='SELFFOUND'
Minimum='1.0.1' IncludeMinimum='yes'
Maximum='1.0.1' IncludeMaximum='yes' />
<UpgradeVersion OnlyDetect='yes' Property='NEWERFOUND'
Minimum='1.0.1' IncludeMinimum='no' />
</Upgrade>
<CustomAction Id='AlreadyUpdated' Error='Foobar 1.0 has already been updated to 1.0.1 or newer.' />
<InstallExecuteSequence>
<Custom Action='AlreadyUpdated' After='FindRelatedProducts'>SELFFOUND</Custom>
<Custom Action='NoDowngrade' After='FindRelatedProducts'>NEWERFOUND</Custom>
</InstallExecuteSequence>
So I'd like to ask you guys How do I check every time I run MSI when I have installed it? Is it installed and the same version, If the same version has been installed, exit the installation process.
回答1:
When you run the "same" MSI again it goes into maintenance mode, often just a repair. Windows doesn't even need to use the MSI you use for this "install" because it uses the original MSI for the install, which may or may not be the one you attempt to install again. So it's not clear what you mean by "the unloading process" or what you expect running the same MSI to actually do.
FindRelatedProducts is for major upgrades, but that means incrementing the ProductVersion and changing the ProductCode. Running the same MSI does not cause a major upgrade (see WiX MajorUpgrade element).
So again, what are you expecting to happen when you run that same MSI again? It seems that you are not uninstalling it, so it will go into maintenance mode using the original MSI file, so there is nothing you can do to change that behavior because it's embedded in the installed product's MSI. Since you are apparently not uninstalling the installed product, it won't remove its registry entries. You should say what those residual registry entries are and why they are residual if in fact the product is not being uninstalled.
回答2:
MSI Zapping: I am not sure what exactly you have done - you seem to have zapped your installed MSI - which is not recommended at all. It can cause serious problems - up to and including total MSI database corruption in the registry.
However, first things first:
MajorUpgrade Element: You can use the more convenient MajorUpgrade Element instead of the older-style elements you are using. Here are the older-Style Upgrade Elements in use. Directly below is a sample of the more modern, MajorUpgrade convenience element
in action:
<MajorUpgrade Schedule="afterInstallInitialize"
DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit."
AllowDowngrades="no" AllowSameVersionUpgrades="no" />
Maybe try this element instead of those you are using. Just comment the old ones out and replace with this simple element. If you do this correctly your major upgrade should work "out of the box". Make sure you specify an UpgradeCode in the Product Element. See the documentation for major upgrades
Relevant Links:
- How to implement WiX installer upgrade?
- Upgrading a WiX generated package with major version zero
- How to implement WiX installer upgrade?
I did not fully understand this section of your question: "When I install my product once and I use the MSI again, the unloading process is performed. However, this does not remove residual information from the registry, which must be cleaned Up using "Windows Installer Clean Up", and when reinstalled, a registry permission issue occurs".
- Zapping: What exactly did you do? Zap the installation? Why? You should be able to successfully uninstall from
Add / Remove programs
? Did that uninstall fail? What is the error message on reinstall? - Modify / Repair: MSI will detect when it is already installed in the same version auto-magically. You will then see the setup's modify / repair dialog show up, and not the first time installation dialogs.
- These modify dialogs only show up if you double click the original MSI files used to install, without rebuilding it. Or you invoke modify from Add / Remove Programs.
- If you rebuild your setup, it will have a new package GUID at the very least, and MSI will then detect that the freshly built MSI is not the one that is already installed, and an error message shows up. Now you can uninstall the current version from Add / Remove programs.
- Related Products: An MSI will also detect if there are related versions installed if you correctly author the Upgrade table - as you seem to do.
- If you generate a new product GUID each time you compile, you will be able to install the new version "on top of" or "side-by-side" with the older installation, unless you author the upgrade table - in which case the older version should be automatically uninstalled as part of the new version's install.
You need to understand package code, product code and upgrade code. The package code is auto-generated for every compile and build. The product code you can set to auto-generate by setting it to * in the product element, or you can hard code it and change it as required. The upgrade code should stay the same once defined. Please google the difference between these different codes - I don't have time to wrap up this explanation right now.
来源:https://stackoverflow.com/questions/51041639/how-do-you-detect-installed-product-versions-at-each-startup