WMI.WaitForServiceState Method

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

Description

The WMI.WaitForServiceState method allows you to delay the test execution until a service running on a local or remote computer goes into the specified state, or until the provided timeout elapses. The computer where the service will be monitored is specified by the WMI.ComputerName property.

Declaration

WMI.WaitForServiceState(ServiceName, State, Timeout)

ServiceName [in]    Required    String    
State [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:

ServiceName

The service’s display name. For example, IIS Admin Service. This is the same value that is displayed in the Name column of the Administrative Tools | Services window and that is specified in the service’s Display name property. This parameter is case-insensitive.

State

The service state to wait for. It can be one of the following string values:

  • Continue Pending
  • Pause Pending
  • Paused
  • Running
  • Start Pending
  • Stop Pending
  • Stopped
  • Unknown

Timeout

The timeout, in milliseconds, to wait until the service goes into the specified state.

Result Value

None.

Remarks

If the service does not go into the specified state during the timeout period, the method posts an error message to the test log.

Example

The following sample code waits for the specified service to go into the Stopped state for the specified period of time.

JavaScript, JScript

// ...
WMI.WaitForServiceState("IIS Admin", "Stopped", 15000);
// ...

Python

# ...
WMI.WaitForServiceState("IIS Admin", "Stopped", 15000)
# ...

VBScript

' ...
Call WMI.WaitForServiceState("IIS Admin", "Stopped", 15000)
' ...

DelphiScript

// ...
WMI.WaitForServiceState('IIS Admin', 'Stopped', 15000);
// ...

C++Script, C#Script

// ...
WMI["WaitForServiceState"]("IIS Admin", "Stopped", 15000);
// ...

See Also

ComputerName Property
GetServiceState Method

Highlight search results