Sys.WaitProcess Method

Applies to TestComplete 15.63, last modified on April 10, 2024


Delays script execution until the specified process appears in the list of processes or the specified time limit is reached. To determine whether the returned object is an extant process, call Exists.

WaitProcess does not launch the process. It simply waits for it for a maximum of Timeout milliseconds.


Sys.WaitProcess(ProcessName, Timeout, ProcessIndex)

ProcessName [in]    Required    String    
Timeout [in]    Optional    Integer Default value: 0   
ProcessIndex [in]    Optional    Integer Default value: 1   
Result The Process object

Applies To

The method is applied to the following object:



The method has the following parameters:


The name of the executable file that launched the process.


Milliseconds to delay the script execution in order to allow the process to start. If Timeout is 0, the method searches for the desired process once and then returns immediately. If Timeout is -1, the waiting time is infinite.


The index of the process instance among those started by the same executable. The first process has index 1, the second - 2, etc. 1 is the default value. If you obtain several processes with the same name and the process with the lowest index is terminated, the indexes of other processes will be decreased by one.

Result Value

The Process object with the specified name. If the specified object does not exist, the method returns an empty stub object.


Unlike the Process method, WaitProcess does not post an error message to the log if the desired process does not exist. It simply returns an empty stub object. Use the Exists property of the returned object to determine whether the desired window exists in the system. If the process exists, its Exists property will return True; the property of the stub object will return False. Note that calling any method of the stub object, except for WaitWindow, will cause an error.


The following example demonstrates how to use the WaitProcess method in scripts:

JavaScript, JScript

p = Sys.WaitProcess("Notepad", 2000);
if (! p.Exists)
  // Process does not exist


p = Sys.WaitProcess("Notepad", 2000)
if not p.Exists:
  # Process does not exist


Set p = Sys.WaitProcess("Notepad", 2000)
If Not p.Exists Then
  ' Process does not exist
End If


var p;
  p := Sys.WaitProcess('Notepad', 2000);
  if not p.Exists then
    // Process does not exist

C++Script, C#Script

var p;
p = Sys["Process"]("Notepad", 2000);
if (! p["Exists"])
  // Process does not exist

See Also

Process Method
Process Object
ProcessName Property
Index Property (Process and Browser Objects)

Highlight search results