I am trying to launch an application with a specific user using runas command. I want to know whether the command is success or not. In manual scenario after entering the password, if I use echo %errorlevel% it returns 0 for successful execution or else 1. But How can I capture the same in Jscript so that I can determine whether my command is success or not. Pls help.
I am using JScript with Testcomplete tool
Add your application to TestedApps, set its Run Mode to RunAs and enter the credentials in the Parameters. Then use the following code:
var p = TestedApps.MyApp.Run(); // replace MyApp with the name of your app in the Project Explorer
if (! p.Exists) {
// runas failed
}
As an alternative to configuring RunAs parameters in the IDE, you can specify them directly in your script code:
var p = TestedApps.MyApp.RunAs("domain", "user", "password");
if (! p.Exists) {
// runas failed
}
BTW, if you are using Windows Vista or Windows 7, make sure to run TestComplete as Administrator in order for this to work.