Micro Focus QTP (UFT) Forums

Full Version: how to run QTP scripts from command line prompt?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I have a requirement to run QTP from command line prompt using a .bat file. Could you please help me how to do this?

Thanks in advance.
Assuming that we have a test script say "Test" on desktop... please include the below code in a vb file namely Test.vbs
Code:
Dim qtApp 'Declare the Application object variable

Dim qtTest 'Declare a Test object variable

Dim qtResultsOpt'Declare a Run Results Options object variable

Set qtApp = CreateObject("QuickTest.Application")' Create the Application object

qtApp.Launch' Start QuickTest

qtApp.Visible = True' Make the QuickTest application visible
qtApp.Open "C:\Documents and Settings\testingsvs_qa\Desktop\Test",True' Open the test in read-only mode

Set qtTest = qtApp.Test
qtTest.Run ' Run the test
WScript.StdOut.Write "The Run Status is:" & qtTest.LastRunResults.Status' Check the results of the 'test run
qtTest.Close' Close the test
Set qtTest = Nothing' Release the Test object
Set qtApp = Nothing' Release the Application object

Now in order to execute QTP script from command line we have to execute the above created vbs file from command prompt which will in turn launch QTP, open the script, run it and will display the result in command prompt only. Open command prompt and write following code: And press enter

C:\Documents and Settings\Ravi_Gajul\Desktop>cscript Test.vbs
Note : C:\Documents and Settings\Ravi_Gajul\Desktop is the location of Test.vbs..update this accordingly

If the script passes the result is declared in command prompt as follows:
The Run Status is: Passed

Regards,
Ravi