Get return code of standard action - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

cajin2
Posts: 8
Joined: Thu May 17, 2007 12:14 am

Get return code of standard action

In Windows installer, there are many standard actions. Is there any way to get the result of the standard action?

For example, "AppSearch" action will search existing installation to decide the new installation will be an upgrade or fresh installation. Can a custom action get the result of AppSearch so it can do something special?
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Hi,
For example, "AppSearch" action will search existing installation to decide the new installation will be an upgrade or fresh installation. Can a custom action get the result of AppSearch so it can do something special?
"AppSearch" standard action allows you to search for a file, component, registry key, folder or INI key on the target computer. The result of your search will be placed in a Property and it can be used in various Custom Actions or Conditions.

"FindRelatedProducts" standard action detects if older versions of the product (product registered with Windows Installer) are already installed. This standard action set the OLDPRODUCTS property if older version were found. OLDPRODUCTS is the property used by AI to store the detected products.

http://msdn2.microsoft.com/en-us/library/aa368600.aspx

So you need to condition the execution of the custom action with the value of OLDPRODUCTS property. If this property is empty then a fresh installation will be done. If not, older versions of the product were found and OLDPRODUCTS property contains their "Product Code".

Regards,
Gigi
______________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com
cajin2
Posts: 8
Joined: Thu May 17, 2007 12:14 am

Not sure why, the OLDPRODUCTS is always empty. I add a custom action after "FindRelatedProducts" with condition as "OLDPRODUTS".

If I don't rebuild the project and run the installer, it shows the "Repair/Modify/Remove" dialog. But does not run my custom action. If I rebuild the project, it just do the installation again and does not run my custom action either.

I tried to add [OLDPRODUCTS] as my command line argument, but it is always empty because my args.Length is always 1.
cajin2
Posts: 8
Joined: Thu May 17, 2007 12:14 am

I set a custom action condition as "Not installed". If I run the installer twice, in the second time, the custom action won't run, that what I expected. however, if I rebuild the project, run the installer again, then the custom action will run. Seems like the new installer package will be treated as a new product. How can we make sure the rebuilt installer is still treated as the old product?
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Hi,

The OLDPRODUCTS property is set only if older versions of the product are already installed. If not the property will be empty.
I set a custom action condition as "Not installed". If I run the installer twice, in the second time, the custom action won't run, that what I expected. however, if I rebuild the project, run the installer again, then the custom action will run.
"Not Installed" is the condition if you want to run a custom action only on install (not on uninstall). With each build a new PackageCode is generated and since the package (with an older "PackageCode") is already installed AI will perform the uninstallation first.

So to run the package only on installation use (Not Installed) as condition for the custom action. But when exactly you want to run that custom action?

Regards,
Gigi
______________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com
cajin2
Posts: 8
Joined: Thu May 17, 2007 12:14 am

Probably I put my different requirements into one post which confused you. To summarize,

1. I want a custom action run when there is an existing installation which was NOT installed by the installer. The background is, some old installations are manually installed (copied files and installed service with other utilities). In this case, the custom action will delete the old files but save some configuration files. - That's why I use 'not installed' as condition.

2. Another custom action will run if the old installation was installed by the installer itself. In this case, the custom action will save the configuration files only. It does not need to delete other files because I suppose the installer itself will do that. - that's why I tried to use "FindRelatedProducts", but it did not work. what's the solution here?

3. In the future, if I have a newer version product, a custom action (similar as item 1) will save the configuration files. Do not delete other program files - I suppose the installer/upgrader itself can do that. - I guess 'FindRelatedproducts' will work here.

4. I hope "rebuild" wont change the package code.
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Hi,

1. You need to determine if the older program is already installed or not. This can be done by using a file or folder search. The result of the search is stored in the RESULT_PROPERTY by default.

The custom action must be conditioned with the result of the search. The CA will run when the package is installed and only if the search succeed. For this use following condition:

Code: Select all

((NOT Installed) AND RESULT_PROPERTY)
2. On upgrade the older version of the product is uninstalled before the new one gets installed. To execute the custom action only on upgrade you can use "OLDPRODUCTS" property as condition. "OLDPRODUCTS" is set if older versions of the product are already installed. In this case you can use following condition:

Code: Select all

((NOT Installed) AND OLDPRODUCTS)
3. If I understand correctly you want to prevent a file from being overwritten by a newer version. If this is the case please see following tutorial on how to do that:
http://www.advancedinstaller.com/user-g ... le-ca.html

Best Regards,
Gigi
______________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com

Return to “Common Problems”