How to run QTP test from command line?

How to run QTP test from command line?

Do you run your QTP tests suit manually?
What about running them on the schedule, for example nightly testing?

I will show the way how to do that - i.e. how to run QTP tests from command line.
Using that approach, you can execute your QTP tests on the schedule.

How to run QTP test from command line - QTP video tutorial

This is a script, which runs QTP tests (from the above QTP video tutorial):
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

qtApp.Open "C:\Temp\simple_test", True ' Open the test in read-only mode

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

WScript.StdOut.Write "Status is:" & qtTest.LastRunResults.Status ' Check the results of the test run
qtTest.Close ' Close the test

Set qtResultsOpt = Nothing ' Release the Run Results Options object
Set qtTest = Nothing ' Release the Test object
Set qtApp = Nothing ' Release the Application object

Happy QTP scripting, dear readers! :)

Related articles:

Do you like this QTP visual tutorial? Would you like to receive them in the future?
If yes, please subscribe to this blog RSS feed or by Email. (How to subscribe? VIDEO guide)


Shashi said...

Hi Dmitry Motevich,
Thanks a lot for ur videos. those are great for a starter like me. Ur blog site gives us lot of information n increases our knowledge in QTP.
A request please load the videos in a format so that we can download easily.
Please focus on Regular Expressions and Descriptive Programming a bit.
Thanks & Regards

Dmitry Motevich said...

Thank you, Shashi, for your comment.

I have several questions on your request:
What video format do you ask?
What file server should I use to store video files?
Who will pay for this file server usage & big generated traffic?

I'm working on video tutorial about Descriptive Programming. So, it will be ready in 1 week.

As for Regular Expressions... This topic is explained on Internet widely. I do not plan to duplicate those articles.

satyam said...


The code for QTP regarding running the script from commandling was very excellent . Can you please concentrate regarding the driver script and Recovery scenarios in the driver script. And how to connect and execute QTP Scripts from QC. Please be a little bit elaborate on this issue.

Any Help in this issue is highly appreciated.


satyam said...


Thanks for presenting such good contents on your blog. The content posted by you is very excellent. In further postings from your side we expect you to post postings related to Recovery scenarios and developing the driver script and running the QTP script from Quality center and posting the results back to Quality Center.

Satyam Reddy

Khizer said...

Thanks very much it was very useful.

Dmitry Motevich said...

I'm glad to hear that!

Deven said...

Dear Dmitry,

It's wonderful video, but if you capture some more stuff such as how to capture checkpoint value, descriptive programming examples, parameterize value set up and merge two different scripts by function call that would be appreciated.


Nice job!! keep it up.


Dmitry Motevich said...

Thank you.
I will try to create QTP videos on others topics

sukanya said...

Thanks for this video,
This is very easy to understand.
I have a request: I am focusing on automating using QTP on a VMware image, The test application is written using Visual C++ and "Windows XP" running on VMware Do you have any details, whether QTP identifies Windows XP image? Please let me know.

Dmitry Motevich said...

What do you mean with "QTP identifies Windows XP image"?
What is "Windows XP image"?

sukanya said...

"Windows XP Image" is is the VMware supported file, (files of format .vmx), If this is opened using VMware, it works as virtual computer with windows xp installed in it.

Dmitry Motevich said...

You didn't answer my another question.

George said...

Hey Dmitry...firstly I have to appreciate the time and effort you have taken to share your are doing a great job helping the community...keep it up !!!

Dmitry Motevich said...

Thank you, George.

thomas_c said...


Thanks you for the video. I use the command line to run my QTP tests using vbscript, however i would like to know if it's possible to run QTP tests with another language like Python...

Thanks. Your blog is very interesting.

Dmitry Motevich said...

to thomas_c (September 11),
The QuickTest automation object model supplies a type library file
named QTObjectModel.dll. This file is stored in 'QuickTest installation folder'\bin.

So, you can access QTP Automation COM object from different programming language. I'm sure that Python provides such possibilities.

Raj said...

Hi Dmitry,

This Video is preety good. Thanks for your effort. But if you will attach the Liberary Function files and Excel sheets to the script then do we need to write any mode code for the executing it?

please let me know for the same.

Best Regards,
Chaitanya Rajkiran

Dmitry Motevich said...

to Raj (September 22),
I didn't get you at all.

What "Liberary Function files and Excel sheet" do you mean?
What is "mode code"?

sivakrishna said...

before watching ur vedio
i had one doubt how to use recovery scenario,now i understood how to do that,i watched ur vedio on recovery scenario its very good ,easy to understand,thanks a lot

Rama said...

Thank you so much for putting this video out there for everyone. It is a big help. I really appreciate the time and effort that you have put to make this so simple and easy to understand.

Rama said...

Thank you so much for putting this video out there for everyone. It is a big help. I really appreciate the time and effort that you have put to make this so simple and easy to understand.

Dmitry Motevich said...

@ sivakrishna & Rama,
Thank you, my dear readers :)

Mars said...

Great! That helps me a lot! Thank you very much!

Lionel said...

Your blog is very good...
Please put more articles on Descriptive programming.
Or if you have time send it to

Dmitry Motevich said...

I recommend to subscribe to my blog and you will get all new published articles and videos


Thank You providing this information.

vincent said...

How do I set up a parameter in the command line and get the parameter in VBScript?

I would like to set up some parameters to make the QTP Test run in different way.
How do I set up the parameters in the command line and how do I retrieve the parameters in the VBScript?

Many thanks for your replying.

Bset Regards,

Anonymous said...

It was nice script

would like something that runs the same way on a remote machine it possible ?

Reggie said...

Hi Dmitry,
First of all...thank you for the time and effort you have put in...

when I run your script I get the following error:
Error: The server process could not be started because the configured identity is incorrect. Check the username and password.
Code: 8000401A

Any ideas how to solve it?

Dmitry Motevich said...

@Anonymous (February 18, 2009),
Answered above.
It's a pity that you didn't read above comments...

Anonymous said...

the script closes the test but keeps the QTP application open. Could you please tell how you can close the application. cos my results are saved in a location and i can go visit them.

Dmitry Motevich said...

@Anonymous (March 5, 2009),

syam said...

How To Run QTP Scripts at Scheduled Time?

Set App = CreateObject("QuickTest.Application")
App.Visible = True
App.WindowState = "Maximized" ' Maximize the QuickTest window
App.ActivateView "ExpertView" ' Display the Expert View "C:\Program Files\Mercury Interactive
\QuickTest Professional\Tests\Test1", False
'Opens the test in editable mode

syam said...

Set App = CreateObject("QuickTest.Application")
App.Visible = True
App.WindowState = "Maximized" ' Maximize the QuickTest window
App.ActivateView "ExpertView" ' Display the Expert View "C:\Program Files\Mercury Interactive
\QuickTest Professional\Tests\Test1", False
'Opens the test in editable mode

Mitchella said...

GREAT video, how do you schedule the task now?

Anonymous said...

Great Video!
Now how do you schedule the task? Do you run the vbs file from the scheduled task on windows?

Anonymous said...

Excellent!! You truly are an expert with this tool. I will always use this blog for all my QTP related queries. Thank you very much.


Jyoti said...

Hi Dmitry

I am recording a dropdown box in my web application.I have to record all the options in the dropdown box and need to put a checkpoint on everylanding page.But the problem is when I try to record every optin individually the script gets too long.Is therea way that I can parameterize the option and the checkpoints.Please help me .Its urgent


Jyoti said...

Hi Dmitry

I need to record a drop down box in my web application.I need to put a check point for every landing page.Is there a we can parameterize the values of the check point .Because when I try to record each option individually from the dropdown box the script gets too long.Please help me its really urgent


Rodrigo said...

Hi Dimitry

I was wondering how would I be able to open Tests that are not stored locally on my machine, e.g Test Director and Quality Center

Dmitry Motevich said...

Dear Readers!
Thank you very much for you comments!

Since this article was published more than one year ago, I've just disabled an adding of new comments for this article.