HPE has a KM document ([KM182570][1]) that shows how to do this. If you have an HPE Passport login you can see it at that link. If not, I will paste the example code below.
Example 1:
Dim App
' Launch QuickTest Professional and make it visible.
Set App = CreateObject(''QuickTest.Application'')
App.Launch
App.Visible = True
' Load an .xml file with the user-defined parameters.
App.Test.Environment.LoadFromFile ''C:Test_Paramsenvironment_file1.xml''
' Declare an array with the paths and names of the tests.
dim testArray(2)
testArray(0) = ''C:Program FilesMercury InteractiveQuickTest ProfessionalTestsmytest''
testArray(1) = ''C:Program FilesMercury InteractiveQuickTest ProfessionalTestsmytest2''
testArray(2) = ''C:Program FilesMercury InteractiveQuickTest ProfessionalTestsmytest3''
Set qtResultsObj = CreateObject(''QuickTest.RunResultsOptions'')
' Loop through all the tests in the testArray.
for i = 0 to UBound (testArray)
' Open the test in QuickTest Professional.
App.Open testArray(i), True
' Get the test object.
Set qtTest = App.Test
' Set the test results options. Here the location for the test results will be set.
qtResultsObj.ResultsLocation = testArray(i) & ''Res1'' ' Set the results location
'Execute the test. Instruct QuickTest Professional to wait for the test to finish executing.
' This statement specifies a test results location.
qtTest.Run qtResultsObj, True
' Run the script using the default test results options.
' qtTest.Run
' Close the test.
qtTest.Close 'Close the test
next
' Close QuickTest Professional.
App.Quit
' Release the created objects.
set qtResultsObj = nothing
set qtTest = nothing
set App = nothing
If you need to modify the test set, you will simply need to modify the array containing the full path and test name. You can also add the statements to load and execute tests directly into the file removing the need for the array and looping statements. This will require more modifications when changes to the test set are needed.
Example 2:
Dim qtApp
Dim filesys
Dim maindir
Dim testCol
Dim checkfolder
Set qtApp = CreateObject(''QuickTest.Application'')
qtApp.Launch
qtApp.Visible = True
' Get the collection of test scripts
Set filesys = CreateObject(''Scripting.FileSystemObject'')
Set maindir = filesys.GetFolder( ''C:Program FilesMercury InteractiveQuickTest ProfessionalTes
tsTesting'' )
Set testCol = maindir.SubFolders
Set qtResultsObj = CreateObject(''QuickTest.RunResultsOptions'')
' Loop through each test in the collection
For each fl in testCol
' Verify the folder is a QTP test
checkfolder = fl.Path & ''Action0''
If (filesys.FolderExists(checkfolder)) Then ' The folder is a QTP test folder
' Open the test.
qtApp. Open fl.Path, True, False
' Set the test results options. Here the location for the test results will be set.
qtResultsObj.ResultsLocation = fl.Path & ''Res1'' ' Set the results location
' Execute the test. Instruct QuickTest Professional to wait for the test to finish executin
g.
' This statement specifies a test results location.
qtApp.Test.Run qtResultsObj, True
' Close the test.
qtApp.Test.Close End If
Next
' Close QuickTest Professional.
qtApp.Quit
' Release the File System Objects
Set testCol = Nothing
Set maindir = Nothing
Set filesys = Nothing
' Release the QuickTest Professional application object
Set qtApp = Nothing
Once you have the VBS file ready, you can execute it by double clicking it or running it from the command line.
I hope that helps.
[1]: https://softwaresupport.hpe.com/group/softwaresupport/search-result/-/facetsearch/document/KM182570