Laurin
Posts: 58
Joined: Thu Jun 12, 2008 4:27 pm

How to determine if it is an upgrade

Hi guys

First: Advanced installer is an amazing tool. Now, it makes fun to create setups. ;-)
2 little questions:

1) I have some sql script which should be only executed the first time. The really first time! So not installed is not enough, because if an upgrade is run not installed is true and my scripts will run again (because the upgrade uninstalls the previous version). So i tried to use (Not installed) and (Not productupgradecode) - without success, my sql scripts run again! So how can i determine if the installation is executed in order of an upgrade?

2) I have added one temporary files in the temp directory. So the file is copied in the temp directory if the install runs and deleted when the install is finalized. That works fine. But if I do an upgrade the temporary file is not there! Is this a bug?

thanks in advance for your help,

kind regards

laurin
dms
Posts: 164
Joined: Tue Aug 28, 2007 7:11 am
Location: UK

Re: How to determine if it is an upgrade

One simple way to determine whether or not this was the first or a subsequent install (because you are doing an update) would be to install a simple registry entry that you set to be permanent. You then make the excecution of your sql script dependent upon the non existance of that registry entry. It does of course mean that you would need to execute the sql script BEFORE the installer creates its registry entries other wise it would always fail to install or alternatively do a conditional search for the entry at the commencement of the installation and use its result as the determining factor.

HTH

Dom
Laurin
Posts: 58
Joined: Thu Jun 12, 2008 4:27 pm

Re: How to determine if it is an upgrade

Hi

thank you for your answer. I know, this would be a possible solution. But i'm quite unhappy with this. advanced installer is such a great tool and what i want to do is a very common task. so - is there no more convenient and more proper way to do this? Why das UpdateProductCode (probably wrote wrong as i have no AI at hand) not work?
If anybody knows a better way any help would be really appreciated,

kind regards

laurin
Laurin
Posts: 58
Joined: Thu Jun 12, 2008 4:27 pm

Re: How to determine if it is an upgrade

Okey, i cracked it. If you use (NOT OLDPRODUCTS) everything works fine!

However I think it's not the aimed behavior that temporary files are removed in a upgrade process after the old version is uninstalled and befor the new one is installed!

kind regards
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: How to determine if it is an upgrade

Hi,
I have some sql script which should be only executed the first time.
This can be done by checking the "at install" checkbox in the "Script Execution" section of the SQL Script page. Also, you need to set the "Script Condition" field to (NOT OLDPRODUCTS) AND (Not Installed).
But if I do an upgrade the temporary file is not there! Is this a bug?
No, this is not a bug. A temporary file is available only during the installation which contains it. Therefore, when the old package is uninstalled by the new one, the temporary file will exist until the uninstall of the old package is complete.

In order to not remove the temporary file after the old version is removed you can use the condition (NOT UPGRADINGPRODUCTCODE). This condition should be set for the temporary file in the old installation package. Note that you can double-click the temporary file in the "Files and Folders" page in order to show the Edit Temporary File dialog.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Laurin
Posts: 58
Joined: Thu Jun 12, 2008 4:27 pm

Re: How to determine if it is an upgrade

Great. Like i figured out... old product is the solution.
thanks!
todo1981
Posts: 13
Joined: Sat Apr 09, 2022 5:01 pm

Re: How to determine if it is an upgrade

I will add to the question and continue and ask, how can I check that it is an update, when the installation was performed from one server, and the update is performed from another server? In such a situation the only test that interests me is the DB and whether it is a first DB installation
or update of DB. Is there a way to know without registering registy?
Catalin
Posts: 6611
Joined: Wed Jun 13, 2018 7:49 am

Re: How to determine if it is an upgrade

Hello,

In order to check for an upgrade, you can use the OLDPRODUCTS property.

This property will be set to the previous version ProductCode if an upgrade is in place, otherwise it will be empty.

Since you do not care about its' value, we can use it as it follows:

Code: Select all

OLDPRODUCTS
this would imply the property exists, therefore it's an upgrade.

or:

Code: Select all

NOT OLDPRODUCTS
which would imply the property does not exist, therefore it is not an upgrade.

Hope this helps!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
todo1981
Posts: 13
Joined: Sat Apr 09, 2022 5:01 pm

Re: How to determine if it is an upgrade

Hi.
Thanks for the answer, but I probably wasn't clear enough.

Identification of an update or not is performed by the registry, right?

But what happens if the original installation was from one server, and the update is performed from another server? The other server does not have the original registry of the original installation.
I'm interested in the DB, not just the app.
Is there a way to run a query in the DB, which will be the flag to be updated? That this is not a new installation? Then according to that continue the installation process? which of course includes an update of the application
Catalin
Posts: 6611
Joined: Wed Jun 13, 2018 7:49 am

Re: How to determine if it is an upgrade

Hello,

The upgrade is detected through one of two properties - either OLDPRODUCTS or UPGRADINGPRODUCTCODE (can not really tell what's going behind the scenes as this is default to Windows Installer).

For more information about this, please have a look over the following articles:

Major Upgrades

How do I determine if an Upgrade is being performed?

Hope this helps!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”