Run program as current user, not installer user...

Answered

Comments

2 comments

  • Avatar
    wojciechka

    It is not currently possible to run the application as the original user if the installer was started as another user.

    We will investigate options for improving this behavior and let you know if there are options for improving it.

  • Avatar
    wojciechka

    The problem is only happening with non-administrative user running installer by logging in as an administrator. Unfortunately it is not possible to handle this on Windows - without knowing the original user's password, it is not possible to run programs as currently logged in user.

    However, it is possible to detect the situation to prevent from running the application as incorrect user. The following XML detects if current user is the currently logged in user. You can use that to show a warning or do not run certain actions by default if ${running_as_loggedin_user} is true or false.

    <initializationActionList> <writeFile> <path>${system_temp_directory}/wmic_get.bat</path> <text>wmic path win32_computersystem get username /value &gt;wmic_output.txt</text> </writeFile> <runProgram> <program>./wmic_get.bat</program> <programArguments></programArguments> <workingDirectory>${system_temp_directory}</workingDirectory> </runProgram> <readFile> <encoding>unicode</encoding> <name>wmic_output</name> <path>${system_temp_directory}/wmic_output.txt</path> <removeBOM>1</removeBOM> </readFile> <deleteFile> <path>${system_temp_directory}/wmic_output.txt</path> </deleteFile> <deleteFile> <path>${system_temp_directory}/wmic_get.bat</path> </deleteFile> <setInstallerVariable> <name>loggedin_user</name> <value>${system_username}</value> </setInstallerVariable> <setInstallerVariableFromRegEx> <name>loggedin_user</name> <pattern>.*UserName=(.*)\\(.*?)\s.*$</pattern> <substitution>\2</substitution> <text>${wmic_output}</text> <ruleList> <regExMatch> <logic>matches</logic> <pattern>.*UserName=(.*)\\(.*?)\s.*$</pattern> <text>${wmic_output}</text> </regExMatch> </ruleList> </setInstallerVariableFromRegEx> <if> <actionList> <setInstallerVariable> <name>running_as_loggedin_user</name> <value>1</value> </setInstallerVariable> </actionList> <conditionRuleList> <compareText> <logic>equals</logic> <nocase>1</nocase> <text>${loggedin_user}</text> <value>${system_username}</value> </compareText> </conditionRuleList> <elseActionList> <setInstallerVariable> <name>running_as_loggedin_user</name> <value>0</value> </setInstallerVariable> </elseActionList> </if> </initializationActionList>

Please sign in to leave a comment.