WMI.WaitForComputer Method

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

The WMI.WaitForComputer lets you delay the test execution until the specified computer is available, the WMI service is running on that computer and the connection to WMI on that computer is established. The method performs multiple attempts to connect to the specified computer until it succeeds or the provided timeout elapses.

The method also lets you specify the user account to use when connecting to a remote computer. You can leave the appropriate parameters blank to connect using the current user account.

Declaration

WMI.WaitForComputer(Computer, User, Password, Timeout)

Computer [in]    Required    String    
User [in]    Required    String    
Password [in]    Required    String    
Timeout [in]    Required    Integer    
Result None

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

Computer

The name or IP address of the computer to whose WMI services you want to connect. For example, "jsmith" or "192.168.1.42". Dot (".") means the local computer.

User

The user name that will be used to connect to WMI on the remote computer. To specify the domain name along with the user name, use the DomainName\UserName format.

Password

The password of the User account that will be used to connect to WMI on the remote computer.

Note: The User and Password parameters must be empty strings in the following cases:
  • When connecting to WMI on the local computer.

  • When connecting to WMI using the current user account.

Timeout

The timeout, in milliseconds, to wait until the WMI connection to the target computer is established. For example, to use the timeout of 2 minutes, specify 1200000.

Result Value

None.

Remarks

After successful completion of the WaitForComputer method, the WMI object is connected to the "root\cimv2" namespace on the target computer.

The method has the following parameters:

Example

The following example demonstrates how to connect to the WMI service on a local computer and post different information about the computer to the log.

JavaScript, JScript

function Test()
{
  // Specifies the local computer using the ComputerName property
  WMI.ComputerName = ".";

  // Using the ConnectToComputer method
  // WMI.ConnectToComputer(".", "", "");


  // Using the WaitForComputer method
  // WMI.WaitForComputer(".", "", "", 1000000);

  // Posts different information about the computer to the log
  WMI.PostProcessorInfo();
  WMI.PostDrivesInfo();
  WMI.PostInstalledAppsInfo();
  WMI.PostEnvironmentVariableInfo();
  WMI.MaxEventCount = 5;
  WMI.PostEventsInfo();
}

Python

def Test1():
  # Specifies the local computer using the ComputerName property
  WMI.ComputerName = "."

  # Using the ConnectToComputer method
  #WMI.ConnectToComputer(".", "", "");

  # Using the WaitForComputer method
  #WMI.WaitForComputer(".", "", "", 1000000);

  # Posts different information about the computer to the log
  WMI.PostProcessorInfo();
  WMI.PostDrivesInfo();
  WMI.PostInstalledAppsInfo();
  WMI.PostEnvironmentVariableInfo();
  WMI.MaxEventCount = 5;
  WMI.PostEventsInfo();

VBScript

Sub Test
  ' Specifies the local computer using the ComputerName property
  WMI.ComputerName = "."

  ' Using the ConnectToComputer method
  ' Call WMI.ConnectToComputer(".", "", "")


  ' Using the WaitForComputer method
  ' Call WMI.WaitForComputer(".", "", "", 1000000)

  ' Posts different information about the computer to the log
  Call WMI.PostProcessorInfo
  Call WMI.PostDrivesInfo
  Call WMI.PostInstalledAppsInfo
  Call WMI.PostEnvironmentVariableInfo
  WMI.MaxEventCount = 5
  Call WMI.PostEventsInfo
End Sub

DelphiScript

procedure Test;
begin
  // Specifies the local computer using the ComputerName property
  WMI.ComputerName := '.';

  // Using the ConnectToComputer method
  // WMI.ConnectToComputer('.', '', '');


  // Using the WaitForComputer method
  // WMI.WaitForComputer('.', '', '', 1000000);

  // Posts different information about the computer to the log
  WMI.PostProcessorInfo;
  WMI.PostDrivesInfo;
  WMI.PostInstalledAppsInfo;
  WMI.PostEnvironmentVariableInfo;
  WMI.MaxEventCount := 5;
  WMI.PostEventsInfo;
end;

C++Script, C#Script

function Test()
{
  // Specifies the local computer using the ComputerName property
  WMI["ComputerName"] = ".";

  // Using the ConnectToComputer method
  // WMI["ConnectToComputer"](".", "", "");


  // Using the WaitForComputer method
  // WMI["WaitForComputer"](".", "", "", 1000000);

  // Posts different information about the computer to the log
  WMI["PostProcessorInfo"]();
  WMI["PostDrivesInfo"]();
  WMI["PostInstalledAppsInfo"]();
  WMI["PostEnvironmentVariableInfo"]();
  WMI["MaxEventCount"] = 5;
  WMI["PostEventsInfo"]();
}

See Also

ComputerName Property
ConnectToComputer Method
Service Property

Highlight search results