Micro Focus QTP (UFT) Forums

Full Version: WScript object in QTP...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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!!!
Hi please don't use WScript.CreateObject("WScript.Network")
Instead give
Code:
Set objNetwork = CreateObject("WScript.Network")
Hi,
Yes, it works! Thank you!
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.
This article explains why you got the error
http://knowledgeinbox.com/articles/vbscr...roduction/
Thanks to all for the detailed explanations... and the link :-)