none
Detecting a product- What is the recommended approach?

    Question

  • I need to execute a custom action as part of my installation package. We are doing a major upgrade which implies that a new product code is generated.
    So i want to conditionalize this action in such a way that it gets executed even with a fresh install as well as with an upgrade.

    This custom action is going to be used in 5 different installers. So i need to detect what product i am currently executing the custom action for.
    So to detect a product, what is the recommended way?
    Should i use the upgrade code to detect a product, especially since an upgrade code will never be changed? Or product code is a better way to detect an installed product?

    What are the other options to detect if a product is installed?

    Thanks in advance
    Kiran Hegde
    Sunday, December 20, 2009 1:25 PM

Answers

  • RemovePreviousVersions already detects older versions and sets a property called PREVIOUSVERSIONSINSTALLED so you can use PREVIOUSVERSIONSINSTALLED as a condition on whatever you want to do.

    Why exactly do you need a condition here? If you're going to run a custom action on a fresh install and an upgrade too, I assume that maybe your custom action may do something slightly different if it's an upgrade, so probably you want to pass PREVIOUSVERSIONSINSTALLED via CustomActionData to tell the CA you're upgrading.



    Phil Wilson
    • Marked as answer by Kiran N Hegde Wednesday, December 23, 2009 8:58 AM
    Monday, December 21, 2009 6:31 PM
    Moderator

All replies

  • Hello Kiran Hegde,

    I am not sure why you want to check a product in custom action. Do you mean when you install product B, you want to know whether product A has been installed (I think it makes no sense to check product itself during installation, check another product make sense)?

    If my understanding is correct. I think check the product code cannot meet the requirement. After you upgrade to a new version, the product code has been changed, you cannot find the previous one in the registry. But the upgrade code cannot be found under product’s uninstall key.

    My suggestion is use a special name for your product. Since the product information can be found under
    HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\
    HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\

    Each product has subkey
    Publisher
    DisplayName


    You can give unique name for all the products developed by your company.
    For example:
    Publisher: Myproduct
    DisplayName: Productv10

    You can loop through the key and read these two sub key’s value. Here is a related thread
    http://social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/afb5012a-30f1-4b96-9931-a143fd76bab5

    If I misunderstood your meaning, please feel free to tell me.

    Sincerely,
    Kira Qian
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework!
    Monday, December 21, 2009 6:56 AM
  • RemovePreviousVersions already detects older versions and sets a property called PREVIOUSVERSIONSINSTALLED so you can use PREVIOUSVERSIONSINSTALLED as a condition on whatever you want to do.

    Why exactly do you need a condition here? If you're going to run a custom action on a fresh install and an upgrade too, I assume that maybe your custom action may do something slightly different if it's an upgrade, so probably you want to pass PREVIOUSVERSIONSINSTALLED via CustomActionData to tell the CA you're upgrading.



    Phil Wilson
    • Marked as answer by Kiran N Hegde Wednesday, December 23, 2009 8:58 AM
    Monday, December 21, 2009 6:31 PM
    Moderator
  • Thanks. This is enough to get me started.
    Wednesday, December 23, 2009 8:58 AM