Archive for August, 2009

Launch QTP by VB Script

Posted by rajivkumarnandvani on August 28, 2009

Hi All,

Some time we required to launch QTP via Script . Here i am showing how to launch QTP via VB script. We can use this for load Library file/ Object repository / Recovery  at qtp Startup. Just copy the script and save the file with .vbs extension

open the vbs file with microsoft based script host OR wsh

‘ This function closes all previous instances/processes of QTP one by one
Public Function  fn_CloseApplication( byval sApplicationExe)
Dim strComputer
Dim objWMIService
Dim colProcesses
Dim objProcess
strComputer = “.”
Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\cimv2”)

Set colProcesses = objWMIService.ExecQuery (“Select * from Win32_Process Where Name = ‘”&sApplicationExe&”‘”)
For Each objProcess in colProcesses
Set objWMIService = Nothing
Set colProcesses=Nothing
End Function

rem  call  function fn_CloseApplication  for close the instances/processes of QTP

call fn_CloseApplication( “QTPro.exe”)
call fn_CloseApplication( “QTAutomationAgent.exe”)

rem  launch QTP
Set objQtpApp = CreateObject(“QuickTest.Application”)
objQtpApp.Visible = True
‘ check the QTP settings
objQtpApp.Test.Settings.Launchers(“Web”).Active = False
objQtpApp.Test.Settings.Launchers(“Web”).Browser = “IE”
objQtpApp.Test.Settings.Launchers(“Web”).Address = “
objQtpApp.Test.Settings.Launchers(“Web”).CloseOnExit = True
objQtpApp.Test.Settings.Launchers(“Windows Applications”).Active = False
objQtpApp.Test.Settings.Launchers(“Windows Applications”).Applications.RemoveAll
objQtpApp.Test.Settings.Launchers(“Windows Applications”).RecordOnQTDescendants = True
objQtpApp.Test.Settings.Launchers(“Windows Applications”).RecordOnExplorerDescendants = False
objQtpApp.Test.Settings.Launchers(“Windows Applications”).RecordOnSpecifiedApplications = True
objQtpApp.Test.Settings.Run.IterationMode = “rngAll”
objQtpApp.Test.Settings.Run.StartIteration = 1
objQtpApp.Test.Settings.Run.EndIteration = 1
objQtpApp.Test.Settings.Run.ObjectSyncTimeOut = 20000
objQtpApp.Test.Settings.Run.DisableSmartIdentification = False
objQtpApp.Test.Settings.Run.OnError = “Dialog”
objQtpApp.Test.Settings.Resources.DataTablePath = “<Default>”
objQtpApp.Test.Settings.Web.BrowserNavigationTimeout = 60000
objQtpApp.Test.Settings.Web.ActiveScreenAccess.UserName = “”
objQtpApp.Test.Settings.Web.ActiveScreenAccess.Password = “”

Posted in QTP | 21 Comments »

%d bloggers like this: