vpodans
Posts: 19
Joined: Tue Dec 27, 2011 3:03 pm

Custom APPDATA path when CurrentUser installation option is chosen

Mon May 24, 2021 5:05 pm

I'm building an x64-only installer with extra InstallTypeDlg dialog where user can choose installation type. What I can't figure out is how to specify custom path to APPDATA variable. To me it defaults to somewhere in %AppData% which is not the right folder in my case. The idea I want to implement is to:
  • When All Users is chosen, use path specified in Install Parameters page. Example: "[ProgramFiles64Folder][Manufacturer]\PowerShell Modules\MyModule"
  • When Current User only is chosen a custom path in "My Documents" must be used and it doesn't generally follow the pattern specified in Install Parameters page. Example "[PersonalFolder]WindowsPowerShell\Modules\MyModule".
I tried to use custom actions an set APPDATA variable to custom by using 'ALLUSERS="1"' condition (ref from MSDN), but neither worked to me. Any way to do this?
®

Catalin
Posts: 4332
Joined: Wed Jun 13, 2018 7:49 am

Re: Custom APPDATA path when CurrentUser installation option is chosen

Wed May 26, 2021 5:51 pm

Hello,

When the "InstallTypeDlg" dialog is used, the APPDIR property can have one of two default values, depending on the user's choice (if it's a per-machine or a per-user installation).

With that being said, what we need to do here is overwrite the default value of APPDIR in case the user has selected the "Only for me" option from the "InstallTypeDlg" dialog.

To do so, we can proceed as it follows:

- go to "Custom Actions" page

- add a "Set property" custom action, without sequence (so we can schedule it on a button push). The custom action can look as it follows:

Property: APPDIR
Value: [PersonalFolder]\SomeOtherFolder


Where "PersonalFolder" is the property that stores the value of the "Documents" folder. More information about this in our Paths of the folders in the "Files and Folders" Page article.

- now please go to "Dialogs" page and select "InstallTypeDlg" dialog

- select the "Next" button and under "Published Events" tab, add the following event:

Event: Execute custom action
Argument: Set property
Condition: AI_INSTALLPERUSER = "1"


Hope this helps!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

vpodans
Posts: 19
Joined: Tue Dec 27, 2011 3:03 pm

Re: Custom APPDATA path when CurrentUser installation option is chosen

Wed May 26, 2021 5:54 pm

- select the "Next" button and under "Published Events" tab
I have only Pro license, can't edit or interact with dialogs.
®

Catalin
Posts: 4332
Joined: Wed Jun 13, 2018 7:49 am

Re: Custom APPDATA path when CurrentUser installation option is chosen

Fri May 28, 2021 3:15 pm

Hello,

Thank you for your followup on this.

This is possible with a Professional license as well, but has some drawbacks.

For instance, the user will not be able to modify the installation location and, in addition to this, the path will still be displayed as the default one.

However, the files will be installed in the "Documents" folder.

To achieve this, please proceed as it follows:

- go to "Custom Actions" page

- under "Wizard Dialogs Stage", right click on any action group

- "Show standard actions" --> "User Selection" --> click on "WelcomeDlg"

- repeat the above and click on the "ProgressDlg" now

- create a "Set property" custom action with sequence and schedule it between the "WelcomeDlg" and "ProgressDlg"

- set its' condition to:

Code: Select all

AI_INSTALLPERUSER = "1"
The drawbacks to this come from the fact that you can not precisely schedule the custom action. Basically, the custom action will be executed after the user selects the installation folder.

So, if the default path is %appdata%, the user changes it to %appdata%\SomeFolder, the files will be installed in the "Documents" folder.

Hope this helps somehow!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”