I am working with QTP 9.2 and want to use "WScript.Shell" with Create Object. I saw some WScript.Shell codes written in QTP Help File but when i copy/paste this code in QTP, it doesn't run. So is there any Add-in required to run this or something else?
[ QUOTE ]
YOu might have just copy pasted code that has statements starting with WScript
Some thing like below
Set x = WScript.CreateObject("x.t")
This won't work as you are not running code in WScript environment but you are running in QTP environment
[/ QUOTE ]
To expand on Tarun's comment...
Most of us stumble on this issue when first working with QTP. Because QTP lifts the Microsoft vbScript documentation/help file entact it contains a few code references that won't work in QTP because QTP provides its own proprietary vbScript runtime interpreter.
If you write a vbScript script and execute it in Windows it is interpreted by the Windows Scripting Host (WSH) runtime interpreter. Execute that same script within QTP and it is interpreted by the QTP runtime interpreter.
The WSH environment has a single built-in object name Wscript and that object is not supported nor available in any way, shape or form in QTP. And there is NO way to instantiate that object. So statements like wscript.echo fail under QTP but work just fine under WSH.
BUT it is possible instantiate a windows shell object in QTP with the following statement:
Set WshShell = CreateObject("wscript.Shell")
This is NOT creating a Wscript object, rather it is creating a window's shell object. Looks similar, but it is not. And this leads to much confusion for new folks to QTP.