Applies to TestComplete 14.30, last modified on November 21, 2019

Description

You can use the RebootAndContinue method if you need to restart your computer during the testing and then continue the test execution with the specified script routine.

To shut down or restart the computer without continuing the test execution, use the Sys.Restart method.

Declaration

aqEnvironment.RebootAndContinue(ScriptProcNamePasswordUserNameDomain)

ScriptProcName [in]    Required    String    
Password [in]    Optional    String Default value: Empty string   
UserName [in]    Optional    String Default value: Current user name   
Domain [in]    Optional    String Default value: Current user domain   
Result Boolean

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

ScriptProcName

Specifies the name of the script routine that will be executed after you have restarted the computer. If the script routine is declared in the same unit where RebootAndContinue is called, you can just specify the routine’s name. If the routine is declared in another unit, its name must be specified in the format unit_name.routine_name.

The routine should not use parameters. To pass information to it, you can either save the needed data to a temporary file, or use project or project suite variables (see Local Variables).

Password

Specifies the password used to log into the operating system after the restart. If the parameter is skipped, TestComplete will use an empty string. This parameter is obligatory if you want to continue test execution under another user account.

UserName

Specifies the account that will be used to log into the operating system after the restart. If you skip this parameter, the current account will be used.

Domain

Specifies the domain to which the user specified by the UserName parameter belongs. If you skip this parameter, TestComplete will use the domain that the current user belongs to.

Result Value

Returns False if the computer failed to reboot. Returns True if the computer started to reboot.

Remarks

After restart, the environment that TestComplete and the tested applications functions in, differs from the environment in which they functioned before the restart. So, script routines have to prepare the environment so that it matches the necessary conditions. For more information on how to do this, see Rebooting the Computer During Automated Testing.

To automatically log on after the restart, TestComplete stores the specified user name, password and domain in the Registry under the \\HKEY_USERS\{USER_SID}\Software\Microsoft\Windows\CurrentVersion\RunOnce Registry key. TestComplete removes this data from the Registry once it has been launched after the restart. However, in some cases the logon parameters may remain in the Registry and they may be used when you restart the operating system. This happens if --

  • If the user account that is used for automatic login does not have permissions for changing the mentioned Registry key.

  • If for some reason the TestComplete process is terminated before the data is removed.

Note that if the legal notice message is displayed upon logging in, TestComplete cannot close it. As a result, the test execution cannot continue after rebooting. To disable this message, assign blank values to the following Registry keys before starting your test:

  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\LegalNoticeCaption
  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\LegalNoticeText

Make sure you have correctly specified the user name, password and domain, especially if you want to log on under another user account. You should also check whether the following conditions are met:

  • The \\HKEY_USERS\{USER_SID}\Software\Microsoft\Windows\CurrentVersion\RunOnce Registry key exists for the user under whose account you want to log in after the restart.

If any of these conditions are not met, the login procedure will fail and the test will not be resumed.

To use the “reboot-and-continue” feature, TestComplete must be running with administrator privileges. See Using TestComplete With Administrator Privileges.

We would like to note once again that the script routine should not use parameters. To pass information to it, you can either save the needed data to a temporary file, or use project or project suite variables (see Using Variables).

Note for Network Suite: You cannot use this method in a network suite. To reboot a host computer, set the Action after run task property to Reboot computer.

Example

The following code demonstrates how you can automatically set a new system language directly from your code. The Main procedure sets the Zulu language as the system language and then restarts the system. After system rebooting, the Unit1.Proc1 procedure is executed under the specified user account (UserName1 and Password1).

JavaScript, JScript

function Main()
{
  aqEnvironment.LanguageForNonUnicodePrograms = "Zulu";
  aqEnvironment.RebootAndContinue("Unit1.Proc1", "Password1", "UserName1", "");
}

Python

def Main():
  aqEnvironment.LanguageForNonUnicodePrograms = "Zulu"
  aqEnvironment.RebootAndContinue("Unit1.Proc1", "Password1", "UserName1", "")

VBScript

Sub Main
  aqEnvironment.LanguageForNonUnicodePrograms = "Zulu"
  aqEnvironment.RebootAndContinue "Unit1.Proc1", "Password1", "UserName1", ""
End Sub

DelphiScript

procedure Main;
begin
  aqEnvironment.LanguageForNonUnicodePrograms := 'Zulu';
  aqEnvironment.RebootAndContinue('Unit1.Proc1', 'Password1', 'UserName1', '');
end;

C++Script, C#Script

function Main()
{
  aqEnvironment["LanguageForNonUnicodePrograms"] = "Zulu";
  aqEnvironment["RebootAndContinue"]("Unit1.Proc1", "Password1", "UserName1", "");
}

See Also

Rebooting the Computer During Automated Testing
Sys.Restart Method
Using Variables

Highlight search results