WMI.CreateProcess Method

Applies to TestComplete 15.69, last modified on November 13, 2024

Description

The WMI.CreateProcess method launches a new process on the computer specified by the WMI.ComputerName property and returns the identifier of the created process.

Declaration

WMI.CreateProcess(CommandLine)

CommandLine [in]    Required    String    
Result Integer

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

CommandLine

The command line to execute. It can include the fully qualified name of the application executable along with the necessary command-line arguments.

Result Value

The identifier (PID) of the created process.

Remarks

The WMI.CreateProcess method cannot be used to launch processes on a remote computer that interacts with the desktop. For example, if you use this method to launch Notepad remotely, the application will start but its window will not appear on screen, that is, it will be running in non-interactive mode. This is a WMI restriction due to security reasons.

The WMI.CreateProcess method returns immediately after having launched the specified process and does not wait for it to finish. To wait for a process to close, you can use the WMI.WaitForProcessExit method.

Example

The following example demonstrates how you can use the CreateProcess method to launch iexplore.exe on the target computer:

JavaScript, JScript

// ...
WMI.ComputerName = ".";
WMI.CreateProcess("C:\\Program Files\\Internet Explorer\\iexplore.exe");
// ...

Python

# ...
WMI.ComputerName = "."
WMI.CreateProcess("C:\\Program Files\\Internet Explorer\\iexplore.exe")
# ...

VBScript

' ...
WMI.ComputerName = "."
Call WMI.CreateProcess("C:\Program Files\Internet Explorer\iexplore.exe")
' ...

DelphiScript

// ...
WMI.ComputerName := '.';
WMI.CreateProcess('C:\Program Files\Internet Explorer\iexplore.exe');
// ...

C++Script, C#Script

// ...
WMI["ComputerName"] = ".";
WMI["CreateProcess"]("C:\\Program Files\\Internet Explorer\\iexplore.exe");
// ...

See Also

ComputerName Property
WaitForProcessExit Method

Highlight search results