I’ll be writing up a longer post on this, but for now I’ll give the short version.
I’m not sure that I’ve exhausted every option, but I’ve run through a lot of scenarios on the ‘override’ options. I’m not happy with some of them, the parameter options seem to have some arbitrary constraints. To supply the password as a literal value, we have to specify ‘asadmin=interactive’. To use the ‘asadmin=interactive’ option, we have to enable connecting to a user session - there must be someone logged on to the endpoint.
This option should work…
override wait
runas=localuser
user=Domain\Alice
password="Alice's Password"
asadmin=interactive
targetuser=Domain\Bob
hidden=true
wait cmd.exe /c d:\abc.bat
What I don’t like about this, is that “Bob” must be logged on, even if we don’t want to interact with him. The override parameters don’t allow a literal password unless we specify ‘asadmin=interactive’, and to do that we need to have some logged-on user with whom to interact (Domain\Bob), even if we are not actually going to interact with the user (hidden=false)
You can use relevance substitutions in the user, password, or targetuser parameters. One relevance I have used quite a bit and I think will be useful for setting targetuser to “whoever is logged on to the machine, since we don’t care anyway” is
targetuser={(preceding text of first "|" of it | it) of concatenation "|" of ((if exists domain of it then domain of it & "\" else "") of user of it & name of it) of logged on users}
However, if there is nobody logged on at all, I don’t think there’s any path to running the script.
Also, one important effect to be aware of - using this option ‘asadmin=interactive’, the script you execute will run with Administrator privileges, even if neither Bob nor Alice are members of the Administrators group.