I call shell to run command in TestComplete:
function RunCommand(cmd, intWindowStyle, waitOnReturn)
{
var shell = new ActiveXObject("WScript.Shell");
if (intWindowStyle != null){
shell.Run(cmd, intWindowStyle, waitOnReturn || false);
} else {
shell.Run(cmd);
}
}Simply i list files and directories in C:\Windows\System32:
RunCommand("cmd /C \"dir C:\\Windows\\System32 > C:\\test.log\"");From log file C:\test.log, i get files and dirs:
2224 File(s) 941,726,810 bytes
80 Dir(s) 2,868,465,664 bytes free
But if run the command directly in command line window, i get different results:
2635 File(s) 1,222,264,966 bytes
88 Dir(s) 2,868,346,880 bytes free
You can see 400+ files and 8 directories less in TestComplete result. I thought TestComplete was running the command in a different account, but when i ran below command in TestComplete, it said it was running as administrator:
RunCommand("cmd /C \"whoami /user > C:\\user.log\"");
/*** Output in C:\user.log ***/
USER INFORMATION
----------------
User Name SID
======================= ===========================================
oyin-win7\administrator S-1-5-21-2771899511-80630353-1606088258-500Can someone tell me what's going on here? Thanks in advance!
Ocean