0
votes

I am using WiX 3.9. Is there a way to get the current logged on user name in Wix. I have been reading lots of online helps and articles but so far nothing helped...maybe I am making some silly mistake. I have added the following code:

  <PropertyRef Id="LogonUser" />

  <Control Type="Edit" Id="UserNameEdit" Width="139" Height="15" X="191" Y="128" Property="USER_NAME" Text="[LogonUser]" />

But this gave me the following error: error LGHT0094: Unresolved reference to symbol Property:LogonUser I have no clue how to fix that.

So I just removed the PropertyRef code but then [LogonUser] is being printed as it is [LogonUser] in the edit box and it does not print the actual user name.

Also when I examine the Install log file I can very well the LogonUser Property as follows:

 Property(C): LogonUser = JS.K

I have used the PropertyRef for WIX_ACCOUNT_USERS etc. and it worked fine but for LogonUser it does not. Am I missing any dll to reference?

2

2 Answers

1
votes

This works for me:

 <Control Type="Edit" Id="UserNameEdit" Width="139" Height="15" X="191" Y="128" Property="USER_NAME" >
<Text>{\DlgTitleFont}USER_NAME</Text>
  <Publish Property="USER_NAME" Value="[LogonUser]" Order="1">1</Publish> 

  </Control>

because you need to explicitly set the property for an edit control.

0
votes

There is no LogonUser afaik. You should create a new property, and initialize it like so:

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

Schedule that before your UI is being shown:

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