hsc
Posts: 71
Joined: Wed Mar 02, 2016 2:55 pm

Installing to %PROGRAMDATA%

Wed Aug 24, 2022 2:32 pm

Hi,

I am creating a custom dialog which lets the user select a folder for data storage. The default location should be %PROGRAMDATA%\Par, and the related property is LOCAL_PAR_DIR. I believe this should be easy to do, but I didn't find a way.

I thought I could simply initialize LOCAL_PAR_DIR in the "Properties" table but didn't find how to use %PROGRAMDATA%. So I initialized LOCAL_PAR_DIR to "[|]" which results in an empty string, and then used a custom action to insert the default value if the property is still empty. This worked.

When I inserted a "browse for folder" button into the dialog, I followed instructions on viewtopic.php?t=1721 which indicate that I should create a "Property Based" folder for the property. Since I did that, the LOCAL_PAR_DIR property is initialized to C:\LOCAL_PAR_DIR, rather than to an empty string, although the value in the "Properties" tale hasn't changed. I created an installation log which confirms that. This prevents my custom action from initializing the property.

Can you help me to overcome my confusion?

Thanks
Hans

Liviu
Posts: 1034
Joined: Tue Jul 13, 2021 11:29 am
Contact:  Website

Re: Installing to %PROGRAMDATA%

Fri Aug 26, 2022 9:51 am

Hello Hans,

In order to achieve your scenario please follow the step from our How to browse for a folder at install time article.

If you still can not get this working, can you please forward to me your .AIP (setup project) file by email to support at advancedinstaller dot com so I can have a look on it?

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

hsc
Posts: 71
Joined: Wed Mar 02, 2016 2:55 pm

Re: Installing to %PROGRAMDATA%

Fri Aug 26, 2022 12:40 pm

Hi Liviu,

thanks for the instruction. I could follow the steps and created the folder and the dialog to define it. However, the initial value of MY_DIR is "C:\" and not "C:\ProgramData" (or rather, %PROGRAMDATA%). Do I have to create a custom action, or is there a predefined property which I can use for initialization?

Thanks
Hans

Liviu
Posts: 1034
Joined: Tue Jul 13, 2021 11:29 am
Contact:  Website

Re: Installing to %PROGRAMDATA%

Fri Aug 26, 2022 12:58 pm

Hello Hans,

In order to achieve this, you can add the [CommonAppDataFolder] peroperty instead of the [WindowsVolume] property at Step 3 of the above tutorial:
3. In the Custom Actions page, create a "Set installer property" custom action with sequence before the "Wizard Dialogs Stage -> Searches" action group. Use the following options for this custom action:

a) Property: MY_DIR (defined in the "Properties" page)

b) Value: [WindowsVolume]
my dir.png
my dir.png (88.05KiB)Viewed 2768 times

Please let me know if that helped you.

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

hsc
Posts: 71
Joined: Wed Mar 02, 2016 2:55 pm

Re: Installing to %PROGRAMDATA%

Fri Aug 26, 2022 1:19 pm

[CommonAppDataFolder] - that was the one I had been looking for! Thanks a lot, Liviu, and have a great weekend.

Hans

Liviu
Posts: 1034
Joined: Tue Jul 13, 2021 11:29 am
Contact:  Website

Re: Installing to %PROGRAMDATA%

Fri Aug 26, 2022 1:42 pm

You're always welcome, Hans!

Have a nice weekend too!

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”