how to run QTP script from command line

171 views
Skip to first unread message

sri

unread,
Apr 10, 2012, 5:44:35 PM4/10/12
to QTP eLearn Team
Hi Team
I'm in a need to run the QTP script from command line. I have save
this code as .vbs file which is executable. when i double click on
that .vbs file, i'm getting an error Microsoft compilation error. IF
this is successful, how can i run from command line?

Is there a way I can run the VB script without QTP installed on a
system? I have to sent my script to my developers, they didn't have
the QTP installed, so they want to run the script without QTP, Pls let
me know if there is a way.


Set myqtp = CreateObject(”QuickTest.Application”)
myqtp.Launch
myqtp.Visible = True
myqtp.Open “C:\Users\bodapats\Desktop\QTP\script\login"
set mytest = myqtp.test
mytest.run
myqtp.close
myqtp.quit
Set myqtp = Nothing


thanks
sri

madhu

unread,
Apr 10, 2012, 6:05:45 PM4/10/12
to sri, QTP eLearn Team

Hi Sri,


Here is the answer for the 1st question.


Go to the command prompt & execute the below command.


cscript.exe test.vbs  (You need to specify the fully qualified path of the vbs file. eg: if the test.vbs is in E:\QTP, then you need to give the command as cscript.exe E:\QTP\test.vbs)


Regards,

Madhu

madhu

unread,
Apr 10, 2012, 6:22:20 PM4/10/12
to sri, QTP eLearn Team
Sri,

For the 2nd question(Running vbscript w/o QTP), go to the link http://www.qtpschool.com/2011/04/running-vbscript-code-without-qtp.html.This will work only if you don't have any objects in your script.

I tried with simple examples, msgbox("Madhu") is working but not print "Madhu". Not sure whether we have any other ways.

Regards,

Madhu

sri

unread,
Apr 10, 2012, 7:11:10 PM4/10/12
to QTP eLearn Team
Is there anything wrong with the script above? why am i getting the
executable error?

madhu

unread,
Apr 10, 2012, 7:18:33 PM4/10/12
to sri, QTP eLearn Team
Try this Sri.

Open the .vbs file in notepad, click on save as, you can see File name, Save as type & Encoding. Now, check whether the Encoding is ANSI or not. If it is not ANSI, then save it as ANSI.

Now, try running again & let us know the result.

Regards,

Madhu


On Tue, Apr 10, 2012 at 5:00 PM, sri <srilat...@gmail.com> wrote:
Thanks Madhu. but  I'm getting the error when I execute the .vbs
file(by double clicking or from command line), saying Invalid
character, CODE : 800A0408, Source: Microsfot VBScript compilation
error

On Apr 10, 3:05 pm, madhu <madhu.s...@gmail.com> wrote:

Chandan

unread,
Apr 10, 2012, 7:51:22 PM4/10/12
to qtp-ele...@googlegroups.com
Hi 

To execute the script above, you would need QTP installed on the machine as you are trying to launch QTP in that VBScript.

In regards to executing Vbscript without QTP, should work fine as long as you are using any QTP specific objects/commands in your vbscript. QTP is dependent upon VBscript not the otherway.

Regards,
Chandan

Jitendra.S

unread,
Apr 11, 2012, 6:35:23 PM4/11/12
to qtp-ele...@googlegroups.com
I got very good site where it( how run the QTP script from command line) explained very good ..

Please go this link

http://motevich.blogspot.com/2008/04/how-to-run-qtp-test-from-command-line.html

sri

unread,
Apr 11, 2012, 11:45:32 PM4/11/12
to QTP eLearn Team
wow nice site. Thank you so much. It was well explained

On Apr 11, 3:35 pm, "Jitendra.S" <jitendra.shah...@gmail.com> wrote:
> *I got very good site where it( how run the QTP script from command line) e*
> *xplained very good ..
>
> Please go this link
>
> http://motevich.blogspot.com/2008/04/how-to-run-qtp-test-from-command...
> *
Reply all
Reply to author
Forward
0 new messages