Shutting Down and Restarting Computer After Test Run

Applies to TestComplete 15.47, last modified on January 20, 2023
Information in this topic applies to desktop and web applications.

In certain cases, you may find it useful to automatically shut down or restart the computer after the test run. For example, when running regression tests on a Friday after your work day is over, you may want the computer to be turned off once the tests are done so that it is not left idle for the rest of the weekend.

TestComplete provides special methods for these scenerios: Sys.Shutdown and Sys.Restart. The Sys.Shutdown method logs off the operating system and then shuts down the computer. The Sys.Restart method does the same and additionally reboots the computer.

Usually, you would add a call to one of these methods at the end of your test or in the OnStopTest event handler to perform shutdown or restart after the test run. For example, to automatically shut down the computer once the test is over, insert the following line at the end of your test:

JavaScript, JScript

Sys.Shutdown();

Python

Sys.Shutdown()

VBScript

Sys.Shutdown

DelphiScript

Sys.Shutdown;

C++Script, C#Script

Sys["Shutdown"]();

To use the Sys.Shutdown or Sys.Restart method, TestComplete must be running with administrator privileges.

When using the Sys.Restart method, please note that it does not log onto the operating system after restart. If you need to reboot the computer, log on and continue test run, call the aqEnvironment.RebootAndContinue method instead. For more information, see Rebooting the Computer During Automated Testing.

See Also

Running Tests
Shutdown Method
Restart Method
Rebooting the Computer During Automated Testing

Highlight search results