WMI.RestartComputer Method

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

Description

The WMI.RestartComputer method shuts down and then reboots the local or remote computer specified by the WMI.ComputerName property via WMI services.

Note that this method does not log onto the target computer. If you need to restart the local computer and continue running the test, use the aqEnvironment.RebootAndContinue method.

Declaration

WMI.RestartComputer()

Result None

Applies To

The method is applied to the following object:

Result Value

None.

Remarks

To restart the local computer, you can also use the Sys.Restart method.

Example

The following example checks if the service current state is Stopped and, if so, restarts the computer.

JavaScript, JScript

// ...
if (WMI.GetServiceState("IIS Admin") == "Stopped")
  WMI.RestartComputer();
// ...

Python

# ...
if (WMI.GetServiceState("IIS Admin") == "Stopped"):
  WMI.RestartComputer()
# ...

VBScript

' ...
If WMI.GetServiceState("IIS Admin") = "Stopped" Then
  WMI.RestartComputer
End If
' ...

DelphiScript

// ...
if WMI.GetServiceState('IIS Admin') = 'Stopped' then
  WMI.RestartComputer;
// ...

C++Script, C#Script

// ...
if (WMI["GetServiceState"]("IIS Admin") == "Stopped")
  WMI["RestartComputer"]();
// ...

See Also

ComputerName Property
ConnectToComputer Method
WaitForComputer Method
Restart Method
RebootAndContinue Method

Highlight search results