drivard
Posts: 50
Joined: Wed Dec 05, 2007 10:14 pm

How to upgrade to a new folder

Hi,
One of our products is changing names, thus we also have a requirement to install to a newly named folder on normal installs as well as upgrades.
I see that upgrades are using the old folder as the target dir.
Is there a way to force the upgrade to install to the new name? If there is a way to do it via AI, that is great, however, if I need a custom action, I can deal with that as well.

We do not allow our users to choose an installation folder.


Thanks,
Dennis
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: How to upgrade to a new folder

Hi Dennis,

You can achieve this from Advanced Installer by doing the following:
- go to the Dialogs page
- select the WelcomeDlg
- select the [ Next ] button on the dialog
- go to the Published Events tab
- create a new SetProperty event, setting APPDIR to:

Code: Select all

[ProgramFilesFolder][Manufacturer]\[ProductName]
This will force the installation of your product to the folder corresponding to your app's new name while upgrading the old installation at the same time.

You could also use a "Property Set with Formatted" custom action on the InstallUISequence in order to set APPDIR to the above value.

Regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
drivard
Posts: 50
Joined: Wed Dec 05, 2007 10:14 pm

Re: How to upgrade to a new folder

Thank you Gabriel! I will give that a try today.
drivard
Posts: 50
Joined: Wed Dec 05, 2007 10:14 pm

Re: How to upgrade to a new folder

Worked perfectly!

Thanks again,
Dennis
drivard
Posts: 50
Joined: Wed Dec 05, 2007 10:14 pm

Re: How to upgrade to a new folder

Hello Gabriel,
I've discovered one unexpected side-effect of this solution.

Our app is launched when the installer finishes. However, when an upgrade happens in the scenario posted in this thread, the app is not launched.

The reason is that it is trying to launch the app using the _OLD_ path, not the new path.

I'm sure there is a workaround for this, but thus far, I have failed to come up with the correct solution.

Any ideas?

Thanks,
Dennis
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: How to upgrade to a new folder

Hi Dennis,

I'm not sure why you are encountering this behavior. Can you please send us the .AIP (project) file you are using to support at advancedinstaller dot com so we can investigate it?

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
drivard
Posts: 50
Joined: Wed Dec 05, 2007 10:14 pm

Re: How to upgrade to a new folder

sent - thank you
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: How to upgrade to a new folder

Hi,

The file is not launched after the upgrade because the APPDIR property was modified, but it was not set as the target installation path. Therefore, Windows Installer considers the old path as the target. Usually the target path is set by the "Next" button on "FolderDlg" dialog. Since you removed this dialog you can add this control event on the "Next" button of "WelcomeDlg" (after the SetProperty event):

Code: Select all

SetTargetPath       APPDIR
Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
drivard
Posts: 50
Joined: Wed Dec 05, 2007 10:14 pm

Re: How to upgrade to a new folder

Thank you Cosmin, I will give it a try and post the results.

regards,
Dennis
drivard
Posts: 50
Joined: Wed Dec 05, 2007 10:14 pm

Re: How to upgrade to a new folder

The solution worked fine for myself, and everyone else that tested it, except for one of our QA engineers
He got a 2872 error, which is apparently because I used [APPDIR] as the value, instead of APPDIR as you had typed it.

I am waiting to hear the results.
drivard
Posts: 50
Joined: Wed Dec 05, 2007 10:14 pm

Re: How to upgrade to a new folder

Removing the brackets worked.

I'm still wondering why the old value worked fine for everyone else.
drivard
Posts: 50
Joined: Wed Dec 05, 2007 10:14 pm

Re: How to upgrade to a new folder

Cosmin,
I just wanted to let you know of a scenario where this whole solution does not work. That is the case of a minimal UI (/qb on the command-line).
The UI sequence will not execute, as I am sure you know.

I'd like to move these two steps to the Execute sequence, so I can be sure they execute. Do you have any recommendation as to where I should place these in the sequence?
I will use my best judgment while I await a response.
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: How to upgrade to a new folder

Hello,

It is best if you place the Property Set with Formatted custom action as early as possible to ensure that the property is properly set before it is used.
Most likely you will want to set it before InstallInitialize standard action.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
bjk68
Posts: 55
Joined: Tue Dec 01, 2009 12:45 pm

Re: How to upgrade to a new folder

GabrielBarbu wrote:place the Property Set with Formatted custom action as early as possible
As said earlier in this thread by Cosmin, changing the APPDIR property is not effective :( . You should use the GUI Control Event SetTargetPath, but this Control Event is not available in quiet mode :( . To make things work with AND without the GUI (quiet mode), you have to use the alternative for SetTargetPath that works in quiet mode: the Custom Action "Directory Set with Formatted" for changing the Appliciation Folder (APPDIR).

The universal solution for upgrading to a new folder that works in GUI mode AND in quiet mode :D :
  • Add a Custom Action "Directory Set with Formatted" to the "InstallInitialize" event.
  • Choose the Application Folder (APPDIR)
  • Set the value (Formatted Text): [ProgramFilesFolder][Manufacturer]\[ProductName] (or any other desired path)
  • Execution Condition: NOT UPGRADINGPRODUCTCODE (this prevents the Custom Action to run during the uninstall phase of an upgrade)
As you see, you don't need to use "Property Set with Formatted" to change the value of APPDIR. Just use "Directory Set with Formatted".
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: How to upgrade to a new folder

Hello,

The Property set with Formatted must be added to both sequences and be set as a shared custom action. Add it under UI Sequence, hold Shift then drag'n'drop the custom action under InstallExecuteSequence. An entry will also appear here.

Shared custom actions are executed only once during the install process. If it executed during UI Sequence, it will not execute under InstallExecuteSequence and vice versa.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/

Return to “Common Problems”