Run QTP test from command line

By | June 25, 2009

Run QTP test script from command line(qc):

Hi friends I have been asked many times this question from my junior colleague, today I am going to share you one script which invoke your qtp test scripts from command line, run it and close it.

You need to just change the path of the your QTP test.

Following is the qtp script to run QTP test script from command line:


Dim qtApp ‘As QuickTest.Application ‘ Declare the Application object variable

Dim qtTest ‘As QuickTest.Test ‘ Declare a Test object variable

Set qtApp = CreateObject(“QuickTest.Application”) ‘ Create the Application object

qtApp.Launch ‘ Start QuickTest

qtApp.Visible = True ‘ Make the QuickTest application visible

‘just enter the path of the QTP test which you want to run.
qtApp.Open “C:\users\QTP\Test”, False ‘ Open the test in read-only mode

‘set run settings for the test
Set qtTest = qtApp.Test

qtTest.Run ‘ Run the test

qtTest.Close ‘ Close the test


If you are facing any issue to run qtp test script from command line you are always welcome to ask. Best Luck!!!

If you like this article, You can subscribe through mail.

2 thoughts on “Run QTP test from command line

  1. abhi

    HI.I have a webtable with 2 column having empid and emn name with nos of rows.if XYZ name having 5 emp id.i want to display the empid of XYZ.can u Pls tell me how could we do.

    empid empname
    123 xyz
    122 abc
    233 mno
    333 xyz
    444 xyz
    354 rty
    456 xyz

  2. Prachi


    I am having Windows 8 (licensed) in my laptop so to use QTP, I have installed “Virtual Box” and running Windows 7 ISO on it. I have installed QTP 10 in that virtual box. I am having Internet Explorer 8 in Win7.

    My issue is, QTP is not recognizing and recording any object when I am trying to write any script or recording anything. Why is it happening I am not able to find out.

    Can u please help me?



Leave a Reply

Your email address will not be published. Required fields are marked *