Forum Discussion

alanbueno8's avatar
alanbueno8
New Contributor
9 years ago

How to read data from a command prompt window / Reading data from cmd.exe - TC c# script

With cmd.exe running, the code below returns the users logged in, read the results and record it in the test log.

 

function functionName()
{
       var p, w, txt, cnt, i, s;

 

       p = Sys.Process("cmd");

 

       w = p.Window("ConsoleWindowClass", "*");

 

       w.Keys("qwinsta [Enter]");

 

       txt = w.wText;

 

       aqString.ListSeparator = "\r\n";

 

       cnt = aqString.GetListLength(txt);

 

       for (i = 0; i < cnt; i++)
       {
            s = aqString.GetListItem(txt, i);

       }

}

 

 

Logged Users

 

Prompt Data