WMI.ComputerName Property

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

Description

The WMI.ComputerName property specifies the computer that the WMI object works with. Assigning a new value to the ComputerName property “connects” the WMI object to the specified computer.

Declaration

WMI.ComputerName

Read-Write Property String

Applies To

The property is applied to the following object:

Property Value

A string that holds the computer name or IP address. For example, "jsmith" or "192.168.1.42". The default value is dot ("."), which means the local computer.

Remarks

The WMI object connects to the "root\civm2" WMI namespace on the target computer.

Note that the ComputerName property connects to the specified computer using the current user account. To connect to a remote computer using a different user name and password, use the WMI.ConnectToComputer method.

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

ConnectToComputer Method
WaitForComputer Method
Service Property

Highlight search results