FGump
Posts: 65
Joined: Thu Jan 05, 2006 7:23 pm

Question on registry key

I've created a setup using AI of my application. I created a search for a file on all drives and used that search as a launch condition. That way only if that file exists (an application's EXE file) then my program will go ahead an install. I also created another search to retrieve a RAW value from a registry key. This value has a path in it where I need to install my files.

My question is: Even though the first search passes (finds the specified file on the target machine), if the registry key doesn't exist what happens? Will it not install or install to the incorrect location. I've told it to install the files to the property (value) obtained from the registry key. So I'm wondering what happens if the key is blank or the key doesn't exist. Is there a way to check the key value and only install if it's valid or present?

Thank you,

FGump
Ionut
Posts: 605
Joined: Tue Nov 22, 2005 11:29 am
Contact: Website

Hi,

The property that stores the result of the Registry Search must be named APPDIR. It will set the Application Folder depending on the data contained by the registry value (if this registry value exists). You have to select "Retrieve the raw value" in the Type combobox.

If the registry value does not exist, the Application Folder will default to the one you set in the Install Parameters page of Advanced Installer.
Is there a way to check the key value and only install if it's valid or present?
Yes, there is, but I advise against this, because your application will not be installed if the registry value does not exist . However, in case you need this behaviour, create another Registry Search named MYAPPDIR (for example). Set the same parameters as described above for the APPDIR property. Then, create a new "Error Message" Custom Action scheduled on the "CostInitialize" stage and set its Execution Condition to: NOT MYAPPDIR.

Regards,
Denis
Denis Toma
Advanced Installer Team
http://www.advancedinstaller.com/
FGump
Posts: 65
Joined: Thu Jan 05, 2006 7:23 pm

Install Parameters

I did what you suggested, but if the registry key is not present then it's defaulting to install to C:\APPDIR. This is not the functionality I want. If the registry key is missing, I don't want the application to install or have it show a message that it couldn't find the install location and let the user choose the location (leave the location shown in the install wizard blank).

Also, when I created the property MYAPPDIR and added the custom action (error message) to the section you described. It never fires! Not even if the registry key is missing.

Am I supposed to be using another Launch Condition for APPDIR?

Thank you for the prompt reply,

FGump

UPDATE:
I see now how I can force a location in the Install Parameters and how APPDIR overrides this. (Too bad I can't leave the install parameter field blank or write in "Choose install location" if the registry key is not found). Also if I set a Launch Condition to the MYAPPDIR, it will refuse to install if the key is not found.
Ionut
Posts: 605
Joined: Tue Nov 22, 2005 11:29 am
Contact: Website

Hi,

The APPDIR property can not be empty because it determines the location where the program will be installed. Advanced Installer uses a Custom Action that sets the value of this property (if it is empty) to whatever you set in the "Application Folder" field (from the Install Parameters page). This Custom Action is scheduled before the "CostInitialize" stage in both Install Sequences ("InstallUISequence" and "InstallExecuteSequence").

You can use the following Script Inline Custom Action to display the value of your property. Schedule this Custom Action on the "CostInitialize" stage, before the Error Message Custom Action.

Code: Select all

MsgBox Session.Property("MYAPPDIR")
I have used the following settings:
A. Install Parameters page - no modifications.

B. Search page:
- APPDIR:
a. "Root" text field set to "HKEY_LOCAL_MACHINE"
b. "Key" field set to "SOFTWARE\temp"
c. "Name" field set to "Install path"
d. "Retrieve the raw value" selected in the "Type" combobox

- MYAPPDIR: the exact same settings as above

C. Custom Actions page:

Code: Select all

- InstallExecuteSequence
    - CostInitialize
        - ScriptInline
            a. "Script text" field set to the above above code (MsgBox ...)
        - ErrorMessage
            a. Execution Condition set to: NOT MYAPPDIR
If the registry value "HKLM\SOFTWARE\temp\Install path" does not exist, the error message is displayed during install and the setup exits. If, on the contrary, this registry value exists, the directory given by the registry value data appears in the "Select Installation Folder" dialog.

Hope this helps.

Regards,
Denis
Denis Toma
Advanced Installer Team
http://www.advancedinstaller.com/

Return to “Common Problems”