Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Execute Vbscript code from QTP
#1
Solved: 10 Years, 9 Months ago
Hi,

I'm in a situation where I cant paste the VBscript code into ATP. So I'm calling it from QTP via a .bat file. The .bat file executes the Vbscript and the execution in QTP moves to the next step. I want QTP to wait till the VBscript completes its execution and then move to the next step. 'Wait' is not a feasible option here. Help?
Its QTP not ATP! For some reason I'm unable to edit this post!
Reply
#2
Solved: 10 Years, 9 Months ago
how do you call the vbscript in QTP? can you paste your lines of code?

Reply
#3
Solved: 10 Years, 9 Months ago
What is achieved out of the .bat file ? Use a Do..While loop and loop until the value is achieved and after that move to the next line.
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply
#4
Solved: 10 Years, 9 Months ago
cd\

wscript C:\DashboardScript\VBSDashboard_Original.vbs

I write these two lines in a .bat file. When the .bat file is called the Vbscript is executed. This Vbscript runs for a longtime but QTP doesn't wait for it to complete the execution. After executing the 'systemutil.run C:\Dashboard.bat' step, the execution is immediately moved to the next step.
Reply
#5
Solved: 10 Years, 9 Months ago
As Basanth suggested, on the very last line have a flag set to some value inside vbs. Now in your Do ... Loop, wait for that value to appear. (Of course don't forget to get some other condition as well, lest the program will go in infinite loop in case some error happens inside vbs.)
Want to fast track your QTP/UFT Learning? Join our UFT Training Course
Reply
#6
Solved: 10 Years, 9 Months ago
Or you can directly call a vbs file through qtp itself rather calling it via a batch file.
see if this thread helps you

Reply
#7
Solved: 10 Years, 9 Months ago
Ya u r right... there's no need to call via a .bat file. It was pretty stupid! Now I'm executing the Vbscript from QTP like this: systemutil.run "C:\Dashboard.vbs". I've set a variable at the end of the script But the prob still persists. The value being set at the end of VBscript is not being passed to QTP!
Reply
#8
Solved: 10 Years, 9 Months ago
try using wscript object as suggested in mentioned thread, put waitonreturn parameter as true to wait QTP until vbs executes
try this
Code:
Dim oShell
Set oShell = CreateObject("Wscript.Shell")
oShell.run "C:\Dashboard.vbs", , True
msgbox "Done"

Reply
#9
Solved: 10 Years, 9 Months ago
Thanks a lot mate. It works! Smile
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Code to run all QTP scripts and see all results Pkapoor 11 16,848 08-15-2017, 02:58 AM
Last Post: Ravi
  How to find and change text in PDF document using QTP UFT automation VBscript alexwhite 0 11,900 02-18-2017, 04:20 AM
Last Post: alexwhite
  Execute button of putton won't be clicke automaticly in UFT (VB) MarUFT 3 2,443 11-21-2016, 04:22 PM
Last Post: Ankur
  Not able to execute script shanthalaAR 0 1,934 06-27-2015, 03:53 AM
Last Post: shanthalaAR
  How to Execute a testset from QC using OTA framework AutomationTester2011 12 51,501 01-21-2015, 09:22 PM
Last Post: karthik_sanakran

Forum Jump:


Users browsing this thread: 1 Guest(s)