Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts

    GetObject Function vs. GetObject Method

    Syntax is just about identical:

    JScript Function:
    Code:
    GetObject([pathname] [, class])
    WSH Method:
    Code:
    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:

    Code:
    try
    {
    	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);
    }
    catch(e)
    {
    	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?
    Last edited by codegoboom; 04-19-2005 at 06:52 AM. Reason: not quite...
    *this message will self destruct in n-seconds*

  • #2
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Looking back, it does show a message without the moniker:

    "Class doesn't support Automation"

    Strange...

    - 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.
    Last edited by codegoboom; 04-19-2005 at 08:04 AM. Reason: lame
    *this message will self destruct in n-seconds*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •