Micro Focus QTP (UFT) Forums
WScript object in 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: WScript object in QTP... (/Thread-WScript-object-in-QTP)



WScript object in QTP... - Maverick - 02-03-2009

Hello,

Could you help, please, to call WScript in QTP

I have a code:
Code:
Set objNetwork = WScript.CreateObject("WScript.Network")

But QTP doesn't accept it and says "Object required:"

Thanks in advance!!!


RE: WScript object in QTP... - manojith1984 - 02-03-2009

Hi please don't use WScript.CreateObject("WScript.Network")
Instead give
Code:
Set objNetwork = CreateObject("WScript.Network")



RE: WScript object in QTP... - Maverick - 02-03-2009

Hi,
Yes, it works! Thank you!


RE: WScript object in QTP... - Prafulla - 02-03-2009

Here is the answer why u r getting the error:
It represents the state of a WSH process(When you click on your vbs file the WSH process starts).The whole point of the WScript object is that it represents everything about the presently running Windows Script Host

The WScript object exposes various properties about the running script and the WSH environment. Now If we run a QTP test, its run in some QTP host but not WSH.

So how can we expect the Wscript Object to be used without a WSH process Actually running.


RE: WScript object in QTP... - tarunlalwani - 02-04-2009

This article explains why you got the error
http://knowledgeinbox.com/articles/vbscript/vbscript-part-1-introduction/


RE: WScript object in QTP... - Maverick - 02-06-2009

Thanks to all for the detailed explanations... and the link :-)