Reading environment variables - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

nitin9
Posts: 6
Joined: Thu Oct 26, 2006 7:22 am

Reading environment variables

Hi,

Basically I want to read say for example an environment variable ALLUSERSPROFILE and get its value in some dialog, so that when that dialog is shown during installation it initializes the control's value to that, which user can always change by selecting a different location.How can I refer to that variable? . Also , in the install parameters page can I add a new property which will refer to the windows environment variable ?. In installer page I want to add a property say p1 whose value is [%somevariable].

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

Hi,
Basically I want to read say for example an environment variable ALLUSERSPROFILE and get its value in some dialog, so that when that dialog is shown during installation it initializes the control's value to that, which user can always change by selecting a different location.How can I refer to that variable? .
This can be achieved very easy with Advanced Installer. After you create the control in the "Dialogs" page switch to "Custom Actions" page and add a "Property set with Formatted" custom action under "InstallUISequence->CostFinalize". Use following options for the custom action:
1. Property Name: MY_PROP
2. Formatted Text: [%ALLUSERSPROFILE]
3. Execution condition: Not Installed

This custom action initialize the control property (MY_PROP) with the expanded value of the ALLUSERSPROFILE environment variable.
In installer page I want to add a property say p1 whose value is [%somevariable].
No, the default value for a property defined in the "Install Parameters" page is plain text only (it is not resolved as environment variable or as msi formatted). You need to create a custom action to set its value with a formatted text.

If it's something that you don't understand please let me know.

Best Regards,
Gigi
______________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com
nitin9
Posts: 6
Joined: Thu Oct 26, 2006 7:22 am

Thanks for the solution. Basically , I wrote a very small inline script for CostFinalize, which read ALLUSERSPROFILE from the system and assigned that to the install property defined in the project , and this property was bound to the edit control of the dialog already.Now during install , when the dialog appeared, then the inline script under CostFinalize did it's job already, and the control showed the expanded value of the environment variable I wanted .The rest was already there.

Thanks And Best Regards
Nitin

Return to “Common Problems”