Micro Focus QTP (UFT) Forums
how to run QTP scripts from command line prompt? - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: how to run QTP scripts from command line prompt? (/Thread-how-to-run-QTP-scripts-from-command-line-prompt)



how to run QTP scripts from command line prompt? - pra6201 - 01-03-2012

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.



RE: how to run QTP scripts from command line prompt? - ravi.gajul - 01-03-2012

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