Process List. Example

Applies to TestComplete 15.10, last modified on December 15, 2021

The following code creates a list of the names for currently running processes and posts one name per line to the test log.

JavaScript, JScript

function TestProc()
{
  var p, i, s;
  for (i = 0; i < Sys.ChildCount; i++)
  {
    p = Sys.Child(i);
    s = "Process Name: " + "\r\n" + p.ProcessName + "\r\n" +
            "\r\n" + "Process Path: " + "\r\n" + p.Path;
    Log.Message(p.Name, s);
  }
}

Python

def TestProc():
  for i in range (0, Sys.ChildCount):
    p = Sys.Child(i)
    s = "Process Name: " + "\r\n" + p.ProcessName + "\r\n" + \
            "\r\n" + "Process Path: " + "\r\n" + p.Path
    Log.Message(p.Name, s)

VBScript

Sub TestProc
  For i = 0 To Sys.ChildCount - 1
    Set p = Sys.Child(i)
    s = "Process Name: " + vbCrLf + p.ProcessName + vbCrLf + _
            vbCrLf + "Process Path: " + vbCrLf + p.Path
    Log.Message p.Name, s
  Next
End Sub

DelphiScript

procedure TestProc;
var
  p, s, i : OleVariant;
begin
  for i := 0 to Sys.ChildCount - 1 do
    begin
      p := Sys.Child(i);
      s := 'Process Name: ' + #13#10 + p.ProcessName + #13#10 + #13#10 + 'Process Path: ' + #13#10 + p.Path;
      Log.Message(p.Name, s);
    end;
end;

C++Script, C#Script

function TestProc()
{
  var p, i, s;
  for (i = 0; i < Sys["ChildCount"]; i++)
  {
    p = Sys["Child"](i);
    s = "Process Name: " + "\r\n";
    s = s + p["ProcessName"] + "\r\n";
    s = s + "\r\n" + "Process Path:" + "\r\n";
    s = s + p["Path"];
    Log["Message"](p["Name"], s);
  }
}

Highlight search results