View Full Version : GetObject Function vs. GetObject Method

04-19-2005, 07:21 AM
Syntax is just about identical:

JScript Function:

GetObject([pathname] [, class])
WSH Method:

WScript.GetObject(strPathname [,strProgID], [strPrefix])

The first two parameters for each are described as being the same...

I'd like to use the third parameter of GetObject to hook events, but can't, because 'WScript.GetObject' fails:

var jsComponent = GetObject("script:c:\\test.wsc");
WScript.Echo(typeof jsComponent); // -> object

var wsComponent = WScript.GetObject("script:c:\\test.wsc"); // -> throws error
WScript.Echo(typeof wsComponent);
WScript.Echo("Hello Failure!"); // -> no real error message available...

Whether or not the "script:" moniker is used, the WSH method fails. (The JS function returns "unknown" without the moniker...)

Is it just me? :confused:

04-19-2005, 08:20 AM
Looking back, it does show a message without the moniker:

"Class doesn't support Automation"


- isn't automation the whole purpose of script components?
- isn't getting an object from a file the main purpose of GetObject?

Maybe it's just me. :rolleyes: