[%USERPROFILE]
is a valid environment variable reference, but I don't think it can be used in this context, as this context isn't formatted. See the Directory Table for details.
Note that, as mentioned in the comments, %USERPROFILE%
is likely the wrong place for any files you may want to install. Consider using another predefined folder, such as AppDataFolder
, LocalAppDataFolder
, or PersonalFolder
.
If you go with PersonalFolder
, I believe you can just use that instead:
<Directory Id="PersonalFolder"> ... </Directory>
If there is no satisfactory predefined folder property, you can use either a type 51 or a type 35 custom action (depending on whether you schedule it before or after CostFinalize to set the run time value of your folder to [%USERPROFILE]
. Those custom actions will format the value they use. Make sure to use an ALL-CAPS name so that it can be set at run time. For example, if the directory is called USERPROFILEFOLDER:
<SetDirectory Id="USERPROFILEFOLDER" Value="[%USERPROFILE]"/>
<!-- or -->
<SetProperty Id="USERPROFILEFOLDER" Value="[%USERPROFILE]"/>
(And don't forget to schedule the action somewhere.)