Runas Current User Failing

Bigfix version 10.0.1.41.

I am trying to run the following action script, but it continues to fail with the message below.

 override wait
 RunAs=currentuser

wait cmd.exe /c del /Q "{value of variable "UserProfile" of environment & "\AppData\Local\Google\Chrome\User Data\Default\Preferences"}"



Command failed (Override keyword is unknown for this command.) override  (action:650794)

Removing override wait, produces the following error message.

Command failed (Process creation failed) run As=currentuser (action:650795)

I think you need to keep the override statement, set the option(s) and the run/wait statement on consecutive lines. You appear to have a blank line before the ‘wait’. As a coder, it looks much nicer, but it baffles the actionscript interpreter.

Also, if you have multiple waits, you have to repeat the override for each one, the settings are not ‘sticky’.

You were correct. Eliminating the blank line, did make a difference. However, it is not running as current user. You can see that it is running as system.

   Command succeeded override wait (action:650917)
   Command succeeded override completion=job (action:650917)
   Command succeeded override hidden=true (action:650917)
   Command succeeded override RunAs=currentuser (action:650917)
   Command started - wait cmd.exe /c del /Q 
"C:\WINDOWS\system32\config\systemprofile\AppData\Local\Google\Chrome\User Data\Default\Preferences" (action:650917)

It may actually be executing as the logged-on user, but the relevance substitution is performed before the command is executed. It may take a couple of tries to figure out the right way to do this, but the first thing I’d try is to use the CMD environment variable instead of a relevance substitution - that should be interpreted by the cmd.exe, rather than by BigFix relevance substitutions.

wait cmd.exe /c del /Q "%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default\Preferences"
2 Likes

Thanks Jason, that worked!

I also tried the following, and it did not work. It ran as system.

override wait
completion=job
hidden=true
RunAs=currentuser
wait delete "{value of variable "UserProfile" of environment & "\AppData\Local\Google\Chrome\User Data\Default\Preferences"}"

Does runas only work with a command shell? The documentation does not say that it only works with a command shell.

RunAs=currentuser mimics RunAsCurrentUser.exe on Windows, using the same logic to identify the current 
user and similar code to create the process with an environment block sourced by the userToken. In case of 
multiple logged-on users, the BES agent chooses the console session if active, or the first logged-on user 
returned from the operating system.

I think it is a question of when the environment variable is evaluated.

In the example of the wait command starting a new command shell, the environment variable will be re-evaluated as the new shell starts.

In the example of using the actionscript delete command, the environment variable will have been evaluated before that (whether at the start of the script or when the Bigfix agent starts, I don’t know).

1 Like

I think it was just too simple. This code appears to work.

delete "{("c:\Users\" & (name of logged on user) & "\AppData\Local\Google\Chrome\User Data\Default\Preferences")}"
3 Likes