email
Posts: 7
Joined: Fri Jan 05, 2007 4:55 pm

Variable Install Path

I'm doing something like this:
http://www.advancedinstaller.com/forums ... light=null
but not exactly.

I need to drop some files in a directory of an app that is already installed. There are two version of the application. If only one is installed than I want to drop the files there, but if both are installed I need to prompt the user to choose one or the other.

What is the best way to do this?

I'm looking in the registry to find the path they applications were installed in. I have radio buttons for the user to pick one or the other. But if only one or neither of the applications are installed it won't work.
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Hi,

I suggest you to add a ComboBox control populated with all paths of that application. You can populate the ComboBox using the Dialog Editor (choose "Control Data..." from the "ComboBox" context menu). On how to dynamically populate a ComboBox please see:
http://www.advancedinstaller.com/forums ... late+combo

As an example on how to add the ComboBox switch to "Dialogs" page, select the "FolderDlg" dialog and replace the "PathEdit" control with a ComboBox control. Type APPDIR in the "Property" field (properties list) of the "ComboBox".

In the script from the post above replace MY_DIR with APPDIR. Note that the APPDIR property represents the installation folder of your package. The approach is similar for other folder but first you need to create that folder in the "Files and Folders" page as "Property based" folder.

Hope this helps. Please let me know if it's something that you don't understand.

Best Regards,
Gigi
_______________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com
email
Posts: 7
Joined: Fri Jan 05, 2007 4:55 pm

re: gigi

I created 3 dialogs, one for each of these cases:
1. User has app A installed
2. User has app B installed
3. User has both installed

I created a combo box on each of these dialogs and changed the 'next' buttons so the logic is correct. However, only one of the combo boxes can have its property set to "APPDIR" at once. Is there a way around this?

thanks for your help
email
Posts: 7
Joined: Fri Jan 05, 2007 4:55 pm

re: gigi

I got this working. thanks. here is the code i used for future reference?

Code: Select all

Set db = Session.Database

On Error Resume Next

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")
 
strKeyPath = "SOFTWARE\MyApp\A"
strValueName = "InstallPath"
oReg.GetExpandedStringValue HKEY_LOCAL_MACHINE,strKeyPath, _
    strValueName,arrValue

    SQLCmd = "INSERT INTO `ComboBox` (`Property`,`Order`,`Value`,`Text`)"
    SQLCmd = SQLCmd & " VALUES ('APPDIR','1','" & arrValue & "rest\of\path" & "','"
    SQLCmd = SQLCmd & arrValue & "rest\of\path" & "') TEMPORARY"     
    Set view = db.OpenView( SQLCmd )
    view.Execute
    view.Close

strKeyPath = "SOFTWARE\MyApp\B"
strValueName = "InstallPath"
oReg.GetExpandedStringValue HKEY_LOCAL_MACHINE,strKeyPath, _
    strValueName,arrValue

    SQLCmd = "INSERT INTO `ComboBox` (`Property`,`Order`,`Value`,`Text`)"
    SQLCmd = SQLCmd & " VALUES ('APPDIR','2','" & arrValue & "rest\of\path" & "','"
    SQLCmd = SQLCmd & arrValue & "rest\of\path" & "') TEMPORARY"     
    Set view = db.OpenView( SQLCmd )
    view.Execute
    view.Close
email
Posts: 7
Joined: Fri Jan 05, 2007 4:55 pm

question

Is there away to change the initial value of the combo box. I am setting APPDIR to a dummy value initially(c:\) because I don't have the path until checking the registry. This value shows up in the combo box by default but I don't want someone to just click next and install to c:\.

Thanks
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Hi,

You can change the default value of the APPDIR property in the "Install Parameters" page ("Application Folder" field). The default value is:

Code: Select all

[ProgramFilesFolder][Manufacturer]\[ProductName]
Best Regards,
Gigi
______________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com
email
Posts: 7
Joined: Fri Jan 05, 2007 4:55 pm

We don't know what we want the default value to be until we check the registry at run time. Can we change APPDIR at runtime with a custom action?

thanks
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Hi,

You can set a value for APPDIR property in your custom action using this code:

Code: Select all

Session.Property("APPDIR") = strPath
But note that AI sets the APPDIR property under "InstallUISequence->RMCCPSearch" standard action and your custom action must be scheduled after this standard action.

Best Regards,
Gigi
_______________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com
email
Posts: 7
Joined: Fri Jan 05, 2007 4:55 pm

THANKS!

Thank you!

Now I'm wondering if it is possible to change the icon that appears in the "Add or Remove Programs" menu?

Thanks again
Phobos
Posts: 85
Joined: Fri Sep 08, 2006 11:52 am
Location: Germany

Hi email,

In the Project Settings -> Product Details section you'll find an option to select the icon used for Add/Remove Programs. That should be what you are looking for.
email
Posts: 7
Joined: Fri Jan 05, 2007 4:55 pm

doh! i should have seen that. thanks.

Return to “Common Problems”