I recently stumbled into a problem while attempting to automate a process that required domain credentials while logged in as a local user. I could use RunWait to run the program, but it would fail unless I was a domain user. When I attempted to use RunAs and RunWait together, I was met with an error that was “possibly related to RunAs.” I mean, who knows for sure what it was related to, am I right? It looked like this:
I am not sure whether this is an oversight, a bug, or done by design, but in any case, it wasn’t gonna work out for me. The workaround here is actually quite simple: Create a .bat file that includes the command you want to run (notepad.exe, in the above example) and then a command to exit the command prompt. RunWait the resulting .bat as your user of choice. Furthermore, if you hide the command prompt, it is perfectly seamless.
I ended up supplying the code to create the .bat from within my script, then deleting the resulting file when it was done. The final result looked something like this:
FileAppend, %commands%, Run.bat
RunAs, realUser, realPassword, realDomain
A little bit more trouble than it probably should be, but hopefully this will suit your needs if you run into this problem. Let me know if you have any better ideas.