Hello Hans,
Thank you for your followup on this.
I thought you were using that support. Now that we are "on the same page", let's review your requirements once again.
Let's start with two definitions here, so we can better understand why and why not some of your expectations can be met.
An update can be of two types:
- a patch
- a major upgrade
1. A patch is basically a
diff between two setup packages, say A and B.
If package A contains the file A.TXT and backage B contains both A.TXT and B.TXT, the patch will only contain B.TXT (the diff between the two).
A major advantage of the patch is its size. As you can imagine, just by containing the B.TXT file, it is much smaller in size.
A big disadvantage of the patch file is that it can not be installed on its own. It will always require the previous version to be installed.
In our case, package A will always need to be installed. Upon applying the patch on that, we will obtain package B.
A more technical explanation of this would be that the patch only contains the differences between the two MSIs tables. As you may already know, an MSI is basically a database. When the patch is applied, the base MSI (package A) is merged with the patch and this is how we obtain package B.
2. A major upgrade, on the other hand, is an independent package. This will automatically uninstall the previous version and then install the newer version.
In case the previous version does not exist on the machine, the package will be treated as a first time installation.
As you can see above (what I've highlighted), a major advantage of the upgrade is that it can be both an upgrade and a first-time installation, unlike the patch which can only be installed if the previous version is already installed.
And, of course, a disadvantage is its size, which is higher than the one of the patch.
Hopefully now we have a better grasp of what each of these terms mean. Let's try to go over your requirements once again and see what and what's not possible:
If the product isn't installed yet, an upgrade install should fail, and so should uninstall, but fresh install should succeed.
This is, as explained earlier, unfortunately, not possible. If the product is NOT installed, then the upgrade will be treated as a first-time installation and therefore succeed.
If an older version is installed, upgrade and uninstall should succeed, but fresh install should fail.
This is, if I understood correctly what you mean, the default behavior of Windows Installer.
For instance, if we have v1.0.0 installed and we install v2.0.0 it will upgrade v1.0.0. The normal uninstall of v1.0.0 will also work as expected.
Regarding the fresh install, this will not work. If you launch the same setup, it will automatically enter Maintenance Mode (giving the user the options to repair/remove the product).
If a younger version is installed, upgrade and fresh install should fail, but uninstall should succeed.
On a machine, if we have v2.0.0 installed and we try to install v1.0.0, it will not work. This is the default behavior of Windows Installer.
Regarding the fresh installation, as previously explained, if v2.0.0 is already installed and we launch again v2.0.0, we will enter the Maintenance Mode.
The uninstall, of course, will succeed (there is no reason why it shouldn't).
I'm trying not to put too much into this conversation... just this: I found the page
https://www.advancedinstaller.com/user- ... -file.html which lists (among others) the command line switches "/newinst <instance_id>" and "/upgrdinst <instance_product_code>" which go into the right direction (uninstall missing) but I don't see how to get <instance_id> or <instance_product_code>.
This refers to the "Multiple Instances" support which you are not using, so we can safely ignore this.
Now, the thing is, although I understand the logic behind your requirements, I'm not quite sure they are achievable.
The main reason for this is that Windows Installer handles this in an automatic manner - you do not have to manually specify that an installation is an upgrade or a fresh installation. The Windows Installer will automatically detect these.
If you have any other questions, please let me know and I will gladly assist.
Best regards,
Catalin