When using the RunAs or RunAsWait functions in AutoIt, you want to run an external program under the context of a different user. While doing this, there can be many things that may be the reason why the functions fails. The AutoIt Function Reference only states that if the function call failed that the return value is zero and that the @error flag is set to non-zero. In order to really know what went wrong, you have to look at the value of the @extended flag.
The table below lists some of the most values of the @extended flag and their meaning. If you encounter other values, please report them via the comments section at the bottom of the page.
|Value of @extended flag||Meaning|
|5 (0x00000005)||ERROR_ACCESS_DENIED - Access is denied.|
|87 (0x00000057)||ERROR_INVALID_PARAMETER - The parameter is incorrect.
You can get this error code when the program you try to execute is an empty string.
|267 (0x0000010B)||ERROR_DIRECTORY - The directory name is invalid.|
|740 (0x000002e4)||ERROR_ELEVATION_REQUIRED - The requested operation requires elevation.|
|1317 (0x00000525)||ERROR_NO_SUCH_USER - The specified account does not exist.|
|1326 (0x0000052e)||ERROR_LOGON_FAILURE - The user name or password is incorrect.|
|1327 (0x0000052f)||ERROR_ACCOUNT_RESTRICTION - Account restrictions are preventing this user from signing in. For example: blank passwords aren't allowed, sign-in times are limited, or a policy restriction has been enforced.|
|1328 (0x00000530)||ERROR_INVALID_LOGON_HOURS - Your account has time restrictions that keep you from signing in right now.|
|1329 (0x00000531)||ERROR_INVALID_WORKSTATION - This user isn't allowed to sign in to this computer.|
|1330 (0x00000532)||ERROR_PASSWORD_EXPIRED - The password for this account has expired.|
|1331 (0x00000533)||ERROR_ACCOUNT_DISABLED - This user can't sign in because this account is currently disabled.|
|1907 (0x00000773)||ERROR_PASSWORD_MUST_CHANGE - The user's password must be changed before signing in.|
|1909 (0x00000775)||ERROR_ACCOUNT_LOCKED_OUT - The referenced account is currently locked out and may not be logged on to.|