Setting property value from another properties

eddyuk picture eddyuk · Jan 3, 2013 · Viewed 13.4k times · Source

I have a custom control (disabled edit) where I want to show current logged in Domain\User.

I set property like this:

<Property Id="PROP_DOMAINUSER" Value="[%USERDOMAIN]\[LogonUser]"></Property>

But what I see in edit box is exact text - [%USERDOMAIN]\[LogonUser] and not actual domain and user.

How do I initialize property value from another property then?

Answer

David Martin picture David Martin · Jan 3, 2013

You need to create a type 51 custom action to set the property, this can be achieved using the SetProperty element. Remember to schedule this before your custom control gets displayed.

<SetProperty Id="INSTALL_USERNAME" Value="[%USERDOMAIN]\[%USERNAME]" /> 

You should then use the property [INSTALL_USERNAME] in your control.

Edit:

To schedule the custom action use the Before or After attribute, if you are unsure where to schedule it use a tool like orca to see what order things are happening in, here's an example of the custom action running after After="InstallInitialize"

<SetProperty Id="INSTALL_USERNAME" Value="[%USERDOMAIN]\[%USERNAME]" After="InstallInitialize" />