nisgupta , we did an admin hack where we set registry keys on Windows machine for auto admin login on restart, then reboot. At end of test, we ran script that unset those keys and rebooted to lock machine again.
This was done a very long time ago and we no longer use TestComplete, so not certain if will work still. Note that some of these script commands use project variables set up in TestComplete, so you will have to implement or substitute actual values.
Sub SetUpDailyRun
' Prepares for the automated test run by enabling auto-logon
' and setting a task to execute for TestComplete
' before rebooting the PC
Dim regKey
If aqEnvironment.IsPluginInstalled("Storages") = True And aqEnvironment.IsPluginInstalled("Win32API") = True And aqEnvironment.IsScriptExtensionInstalled("WMI Object") = True Then
Set regKey = Storages.Registry("SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", HKEY_LOCAL_MACHINE, getRegArch())
Call regKey.SetOption("AutoAdminLogon", "1")
If regKey.GetOption("AutoAdminLogon", "<none>") <> "1" Then Log.Error "Failed to set ""AutoAdminLogon""."
Call regKey.SetOption("AutoLogonCount", "1")
If regKey.GetOption("AutoLogonCount", "<none>") <> "1" Then Log.Error "Failed to set ""AutoLogonCount""."
Call regKey.SetOption("DefaultUserName", Project.Variables.WinUser)
If regKey.GetOption("DefaultUserName", "<none>") <> Project.Variables.WinUser Then Log.Error "Failed to set ""DefaultUserName""."
Call regKey.SetOption("DefaultPassword", Project.Variables.WinPassword)
If regKey.GetOption("DefaultPassword", "<none>") <> Project.Variables.WinPassword Then Log.Error "Failed to set ""DefaultPassword""."
Call regKey.SetOption("DefaultDomainName", Project.Variables.WinDomain)
If regKey.GetOption("DefaultDomainName", "<none>") <> Project.Variables.WinDomain Then Log.Error "Failed to set ""DefaultDomainName""."
Set regKey = Storages.Registry("SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce\", HKEY_LOCAL_MACHINE, getRegArch())
Call regKey.SetOption("TestCompleteTask", """" & aqFileSystem.IncludeTrailingBackSlash(Project.Path) & "task.vbs" & """")
If regKey.GetOption("TestCompleteTask", "<none>") <> """" & aqFileSystem.IncludeTrailingBackSlash(Project.Path) & "task.vbs" & """" Then Log.Error "Failed to set ""TestCompleteTask""."
' This call stopped working in 06/2013
' for running when user logged out
'Call Sys.Restart()
Call WMI.RestartComputer()
Else
Log.Error "Required extensions are not installed.", "You must enable ""Storages"" Extension, ""Win32API"" Extension, and ""WMI"" Script Extension."
End If
End Sub 'SetUpDailyRun
Sub CleanUpDailyRun
' Cleans up after an automated run by
' disabling auto-logon
' and deleting the TestComplete task
' before rebooting
Dim regKey
If aqEnvironment.IsPluginInstalled("Storages") = True And aqEnvironment.IsPluginInstalled("Win32API") = True Then
Set regKey = Storages.Registry("SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\", HKEY_LOCAL_MACHINE, getRegArch())
Call regKey.SetOption("AutoAdminLogon", "0")
If regKey.GetOption("AutoAdminLogon", "<none>") <> "0" Then Log.Error "Failed to set ""AutoAdminLogon""."
Call regKey.RemoveOption("AutoLogonCount")
If regKey.GetOption("AutoLogonCount", "<none>") <> "<none>" Then Log.Error "Failed to delete ""AutoLogonCount""."
Call regKey.RemoveOption("DefaultUserName")
If regKey.GetOption("DefaultUserName", "<none>") <> "<none>" Then Log.Error "Failed to delete ""DefaultUserName""."
Call regKey.RemoveOption("DefaultPassword")
If regKey.GetOption("DefaultPassword", "<none>") <> "<none>" Then Log.Error "Failed to delete ""DefaultPassword""."
Call regKey.RemoveOption("DefaultDomainName")
If regKey.GetOption("DefaultDomainName", "<none>") <> "<none>" Then Log.Error "Failed to delete ""DefaultDomainName""."
Set regKey = Storages.Registry("SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce\", HKEY_LOCAL_MACHINE, getRegArch())
Call regKey.RemoveOption("TestCompleteTask")
If regKey.GetOption("TestCompleteTask", "<none>") <> "<none>" Then Log.Error "Failed to delete ""TestCompleteTask""."
Call Sys.Restart()
Else
Log.Error "Required extensions are not installed.", "You must enable ""Storages"" Extension and ""Win32API"" Extension."
End If
End Sub 'CleanUpDailyRun
Function getRegArch()
' Returns constant for registry architecture for use in Storages.Registry
If Sys.OSInfo.Windows64bit = True Then
getRegArch = AQRT_64_BIT
Else
getRegArch = AQRT_32_BIT
End If
End Function 'getRegArch