Hmm. Using standard "runas", %ERRORLEVEL% is set to "1" on a login failure.
Here is a simple work-around to test if the login is likely to work:
code:
$sStatusFile='C:\TEMP\RunAs_OK.txt'
$sUser='DOMAIN\username'
$sPass='Secret'
; Remove previous run failures
If Exists($sStatusFile) Del $sStatusFile EndIf
Shell '.\runas /user:'+$sUser+' /pass:'+$sPass+' %COMSPEC% /C echo Success >'+$sStatusFile
If @ERROR OR %ERRORLEVEL%
"ErrorLevel="+%ERRORLEVEL%+", Error="+@ERROR+" "+@SERROR
Exit @ERROR | %ERRORLEVEL%
EndIf
If Exists($sStatusFile)
Del $sStatusFile
"Runas Succeeded."+@CRLF
Else
"Runas failed. Error unknown"+@CRLF
EndIf
The temporary file will not be created if the login fails, so you can use this as a test.
Even better if you can create this sort of sentinel file in the actial process that you are launching.