How can I find out the name of the user which has launched the installer?

Answered

Comments

1 comment

  • Avatar
    Jake

    There is an internal variable automatically set by the installer: ${system_username}. It works in all supported platforms, including Windows.

    However, if you launched the installer using sudo and want to check the logged user, you can use ${env(SUDO_USER)}:

    <!-- SUDO_USER is defined just when using sudo -->
    
    <setInstallerVariable name="username" value="${env(SUDO_USER)}"/>
    
    <setInstallerVariable name="username" value="${system_username}">
       <ruleList>
          <!-- Accessing non-existent environment variables result in an empty string -->
          <compareText text="${username}" logic="equals" value=""/>
       </ruleList>
    </setInstallerVariable>
    

    Thanks to Fabrizio Vitale for providing this information.

Please sign in to leave a comment.