Micro Focus QTP (UFT) Forums
Execute Vbscript code from QTP - 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: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Execute Vbscript code from QTP (/Thread-Execute-Vbscript-code-from-QTP)



Execute Vbscript code from QTP - nitin7.j@tcs.com - 10-21-2009

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!


RE: Execute Vbscript code from QTP - Saket - 10-21-2009

how do you call the vbscript in QTP? can you paste your lines of code?


RE: Execute Vbscript code from QTP - basanth27 - 10-21-2009

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.


RE: Execute Vbscript code from QTP - nitin7.j@tcs.com - 10-21-2009

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.


RE: Execute Vbscript code from QTP - Ankur - 10-21-2009

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.)


RE: Execute Vbscript code from QTP - Saket - 10-21-2009

Or you can directly call a vbs file through qtp itself rather calling it via a batch file.
see if this thread helps you


RE: Execute Vbscript code from QTP - nitin7.j@tcs.com - 10-22-2009

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!


RE: Execute Vbscript code from QTP - Saket - 10-22-2009

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"



RE: Execute Vbscript code from QTP - nitin7.j@tcs.com - 10-22-2009

Thanks a lot mate. It works! Smile