Get install path from registry - 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!

dawies
Posts: 40
Joined: Thu Jun 23, 2011 7:03 am

Get install path from registry

Hi there,

This is hopefully the last time I'm bugging you today ;)

I am trying to get an install path from the registry. Ie I want to check a registry key and if it exist the INSTALL_PATH = value + FOLDER_NAME if not check the next registry key if it exists INSTALL_PATH = value2 + FOLDER_NAME and so on. If I get to the end and none of the value where found then display a message to the user and abort installation.

I have added searches for these value but not sure how to put it all together.

Thank you in advance.

regards,

Dawie
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Get install path from registry

Hi Dawie,

Here is a similar thread that demonstrates this with one registry search. You can add several searches and custom actions for every registry value, like described in the sample.

If you know that only one registry value exists on the target machine then the custom action order shouldn't matter. However multiple searches could return values. In this case you should keep in mind the appropriate order in the Custom Actions page, because the APPDIR will remain set by the last "Set Property with Formatted" custom action in the sequence.

You should also add a "Property set With Formatted" custom action at the beginning of the others. This custom action should assign the APPDIR to something like "NOT SET". At the end of all the searches, you should add an "Error message" custom action with the following condition:

Code: Select all

APPDIR = "NOT SET"
This way the installation will stop and rollback if all the searches fail. For more information please read the "Error Message" custom action user guide reference under this link.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
dawies
Posts: 40
Joined: Thu Jun 23, 2011 7:03 am

Re: Get install path from registry

Thank you lots :)
dawies
Posts: 40
Joined: Thu Jun 23, 2011 7:03 am

Re: Get install path from registry

Hi there,

I have been trying the above but not working :( I have added searches APP_DIR1 - APP_DIR5. I have added custom actions PropertySource 1 - PropertySource 5 under InstallUISequence->AppSearch and PropertySrouce1.1 - PropertySource1.5 under InstallExecuteSequence->AppSearch.

Property Name [APP_DIR1-5] Formatted Text [APPDIR] expression APP_DIR1-5

If I run the installation, it just installs in [ProgramFilesFolder][Manufacturer]\[ProductName]

Am I missing something?

regards,

Dawie
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Get install path from registry

Hello,

Have you used the "Property set with Formatted" custom action like mentioned in our user guide reference here ?

Also, here is the reference to the formatted type. Please make sure that the public properties references in the Formatted Text filed are resolved as intended.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
dawies
Posts: 40
Joined: Thu Jun 23, 2011 7:03 am

Re: Get install path from registry

Hi there,

I tried running the example on the first link that you posted, however it does not seem to work and keeps installing to the property that was set at Install Parameters and not the value from the registry. Can I attach my project file for someone to look at as I'm not getting this to work and getting sorta frustrated by the amount of time I'm spending on this?

regards,

Dawie
Last edited by dawies on Tue Jul 05, 2011 11:30 am, edited 1 time in total.
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Get install path from registry

Hello Dawie,

I have looked into your .AIP file and here is what you need to do to correct it:
  • remove the execution condition from the first custom action in the sequence
  • disable the "Run when patch is uninstalled" option from the same custom action
  • change the formatted text field of the same custom action to( remove the quotes ):

    Code: Select all

    NOT SET
  • do not create new custom actions for the InstallExecuteSequence, just share them by holding the Shift key and dragging them from the InstallUISequence
  • enable the "Execute only once if present in both sequence tables" scheduling option for all custom actions
  • to make sure the custom actions execute only on install, add the following to each custom action's execution condition:

    Code: Select all

    AND (Not Installed)
  • make sure the shared custom actions have the same execution condition in both sequences
Hope this helps,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
dawies
Posts: 40
Joined: Thu Jun 23, 2011 7:03 am

Re: Get install path from registry

Hi there,
I have tried exactly what you suggested and it still does not work. I've tried the following expressions: %APPDIR = "", %APPDIR = "NOT SET", APPDIR = "", APPDIR = "NOT SET", NOT %APPDIR and none of these work. I have added a messagbox to show the value of APPDIR and APPDIR1 and it shows the correct path when it's there and nothing when it was not in the registry.

How do I get the condition to run when APPDIR is empty?

regards,

Dawie
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Get install path from registry

Hello Dawie,

Please note that:

Code: Select all

NOT SET
is not a property logical reference indicating the APPDIR property is empty. It is simply a string that will remain assigned to the APPDIR property if all the searches return nothing. This way the "Error Message" custom action can stop the installation.

I have tested this on my machine and it works. Simply set the APPDIR to:

Code: Select all

NOT SET
in the first "Property Set with Formatted" custom action and condition the "Error Message" custom action with:

Code: Select all

APPDIR = "NOT SET"
All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
dawies
Posts: 40
Joined: Thu Jun 23, 2011 7:03 am

Re: Get install path from registry

Thank you again for the quick reply.

I have done this, however after the search was run and nothing was found the APPDIR is set to nothing "" if I display it with a messagebox. Have I maybe overlooked a different setting in the search or something?

regards,

Dawie
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Get install path from registry

Hi Dawie,

If the first "Set Property with Formatted" is the one setting APPDIR to

Code: Select all

NOT SET
then the APPDIR can be empty only if somehow the in-between custom action get executed. You can add a MessageBox custom action after each and find out when its value changes from NOT SET to "".

The APPDIR should remain set with NOT SET until the "Error Message" if all the searches fail, thus triggering it.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
dawies
Posts: 40
Joined: Thu Jun 23, 2011 7:03 am

Re: Get install path from registry

That is exactly what I've done, it sets APPDIR to NOT SET and then after the search it is set to nothing "".

I've attached another example.
Attachments
test.aip
(10.01 KiB) Downloaded 1023 times
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Get install path from registry

Hi,

This is the normal behavior because the "PropertySource_1" custom action always gets executed. If successful, a search operation returns the mentioned value, otherwise its associated public property is set to a blank string.

As suggested before, please correct the following in the project you attached:
  • the condition for the "PropertySource_1" custom action should be the search name public property so that it gets executed only when the search retrieves a value:

    Code: Select all

    APPDIR1
  • the condition for the "ErrorMessage" custom action should be:

    Code: Select all

    APPDIR = "NOT SET"
    and not

    Code: Select all

    %APPDIR = "NOT SET"
All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
dawies
Posts: 40
Joined: Thu Jun 23, 2011 7:03 am

Re: Get install path from registry

Thank you Mihai. It works :)

What is the difference between %APPDIR and APPDIR?

Thank you for all your help :) Much appreciated.

kind regards,

Dawie
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Get install path from registry

Hi Dawie,

"%APPDIR" -> is interpreted as the environment variable with the name APPDIR

"APPDIR" -> is interpreted as a public property with then name APPDIR

So they will both be resolved to different values, since most likely the environment variable APPDIR was not existing it was resolved to an empty string.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”