Runascurrentuser as well as Environment variable question

(imported topic written by SystemAdmin)

This seems like it should be so simple - but my script keeps failing.

I am deploying an msi, and it needs to have the %username% variable passed to it. Here are the iterations of what I have tried.


wait __Download\RunAsCurrentUser.exe --w cmd.exe /c msiexec.exe /i __Download\agentsetup.msi /qn LDAPID={value of variable “USERNAME” of environment}


That fails both the debugger as well as actually trying to deploy. If I need the username variable, I need to use RunAsCurrentUser - right?

Anyway, when I remove the runascurrentuser, it will pass the debugger, but still fails when I try to deploy.


wait msiexec.exe /i /qn __Download\agentsetup.msi LDAPID={value of variable “USERNAME” of environment}


Works fine if I pass it text instead of the environment variable. Fails every time when I add the {value of variable “USERNAME” of environment}.

I have searched the forums and the documentation, and cant figure out what I am missing. Any ideas?

(imported comment written by BenKus)

The variable “username” might not exist for the SYSTEM account. And since the agent will substitute the relevance before the action runs (thus not using RunAsCurrentUser for the relevance substitution) it would fail if the variable didn’t exist.

You can try just using the built-in command-line resolution like this:

wait __Download\RunAsCurrentUser.exe --w cmd.exe /c msiexec.exe /i __Download\agentsetup.msi /qn LDAPID=%USERNAME%

Ben

(imported comment written by SystemAdmin)

That must be it then. If I run it like you listed, it doesnt fail, but it passes the actual text “%username%”. Any solutions then for passing the username variable?

(imported comment written by SystemAdmin)

Is there no way to pass the username variable to the script then?

(imported comment written by SystemAdmin)

If you know that only 1 user will be logged on, maybe you could use…

wait __Download\RunAsCurrentUser.exe --w cmd.exe /c msiexec.exe /i __Download\agentsetup.msi /qn LDAPID={name of logged on user}

Paul

(imported comment written by SystemAdmin)

That did it!! Thank you!

(imported comment written by JackCoates91)

might want to add

number of logged on users = 1

(imported comment written by SystemAdmin)

Good one Jack. Yeah, he should add that to his relevance (not the action).

(imported comment written by SystemAdmin)

Will do, thanks guys!