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!

Dural
Posts: 2
Joined: Wed Oct 01, 2014 11:11 am

How to get an exist value from Registry and use it?

Please how is it possible to get a value from a allready exist RegistryValue?

In Inno Setup it's very easy. For example, with this code, I can get a string from the Registry and put it in variable "DefaultDirName"

Code: Select all

DefaultDirName={reg:HKLM\SOFTWARE\MyCompany\MySpecialPath,MyAppDir|{pf}\MyAppName}
I need to to this in AI for setting "Application folder" (in "Install Parameters") like this:

Application folder = [HKLM\SOFTWARE\MyCompany\MySpecialPath] OR IF SpecialPath ISN'T EXIST = [[ProgramFilesFolder]\[ProductName]]

And also I need a error message with stop the installation, if another key in registry ins't exist.

Like this: IF [HKLM\ABC\RegistryValue]<>'123' SHOW Message "Sorry, Installation not possible! Please open www.moreinformations123.com for details!"

(How) is this possible with AI Professional?
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: How to get an exist value from Registry and use it?

Hello and welcome to our forums,

What you want to achieve can be done through our predefined support for "Searches" and "Custom Actions".

Here is a step-by-step process which you can follow in order to achieve what you want:

- go to "Search" page and create a new search (right click under "Target Computer" --> "New Search").

- now right click on your search --> "Add search location" --> "Registry".

- now configure the search as per your needs. For instance, for a registry key-value pair like this:
Capture1.PNG
Capture1.PNG (45.32 KiB) Viewed 5281 times
the search could be configured like this:
Capture2.PNG
Capture2.PNG (17.38 KiB) Viewed 5281 times

- now that we have created and configured the search, it is time to create a MessageBox custom action which will display your desired message. To do so, you can proceed as it follows:

- go to "Custom Actions" page and add a "Display message box" custom action.

- after doing so, simply condition it based on the earlier created search.

Hope this helps.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Dural
Posts: 2
Joined: Wed Oct 01, 2014 11:11 am

Re: How to get an exist value from Registry and use it?

Thank you very much!

It works fine, but 've two last questions:

First, how can I set the alternate destination-path, if the registryValue is empty?

What I mean is the end of this pseudo-code:
Variable = [HKLM\SOFTWARE\MyCompany\MySpecialPath] OR IF SpecialPath ISN'T EXIST = [ProgramFilesFolder]\[ProductName]

And the last question, how to cancel/abort the installation if the MessageBox was displayed and the user click cancel?

I Know the condition > BTN_PRESSED="IDNO", so this is not my problem, I'm looking for something like go to ExitDialog or ExitInstaller...?
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: How to get an exist value from Registry and use it?

Hello,
First, how can I set the alternate destination-path, if the registryValue is empty?
I am afraid that this is not possible by using our predefined support for searches. This is happening because the Windows Installer does not guarantee the searches order, so a new search should not use the result of another search. As an alternate solution, you can create your own custom action (e.g. PowerShell, VBS) that will search for the respective registry entries.
And the last question, how to cancel/abort the installation if the MessageBox was displayed and the user click cancel?
This can easily be done by placing a custom action after your message box that will return an exit code equal to 3. Windows Installer interprets any exit code different than "0" as unsuccessful, so your setup will end. This can be achieve as it follows:

- after your "MessageBox" custom action, add a "PowerShellScriptInline" custom action with the following content:

Code: Select all

exit 3
- condition your custom action with the following condition:

Code: Select all

((VersionNT > 501) OR (VersionNT = 501 AND ServicePackLevel >= 2)) AND BTN_PRESSED="IDCANCEL"
from under the "Execution Stage Condition" section.

Hope this helps.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”