Prev: RUNAS+.exe
Next: Wake on LAN
From: Joe Marriott on
G'day,

Can someone help me connect to a WSC with an event sink?

Here is the wsc code as generated by Windows Script Component Wizard.
****************************************** START
<?xml version="1.0"?>
<component>

<?component error="true" debug="false"?>

<registration
description="test2"
progid="test2.WSC"
version="1.00"
classid="{00ae53a6-9647-44b3-b337-cfb1e29fa5dc}"
>
</registration>

<public>
<method name="TestMethod">
</method>
<event name="TestEvent"/>
</public>

<implements type="Behavior" id="Behavior"/>

<script language="JScript">
<![CDATA[

var description = new test2;

function test2()
{

this.TestMethod = TestMethod;
}

function TestMethod()
{
return "Temporary Value";
}

]]>
</script>

</component>
***************************************************END

The wsc component is registered and then I try and use the following VBS
script (test.vbs):

***************************************************
set x = WScript.CreateObject("test2.WSC", "x_")

sub x_TestEvent()
msgbox "Hello"
End Sub

******************************************************

Every time I run test.vbs, I get the error "Could not connect object" Code:
80020009

The error occurs whether I use vbs or jscript for the wsc object, and it
occurs whether I use"test2.wsc" or "script://c:\test2.wsc" as the
CreateObject parameter.

Much appreciated,
Joe Marriott


From: mr_unreliable on
Joe, I am answering the question that you didn't ask.

You are not going to get any "TestEvent" events, because
you don't use "FireEvent" anywhere in your component.

I suggest re-reading this page in your wsc doc:

"Exposing Custom Events in Behavior Script Components"

As to the "can't connect" error, that usually means that
the component is not registered properly, (even though
you are asserting that it was)...

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)


Joe Marriott wrote:
> Can someone help me connect to a WSC with an event sink?
>
From: Joe Marriott on
Hi jw,

Thanks for replying. I was able to resolve the issue, I had to remove the
line <implements type="Behavior" id="Behavior"/> from my wsc. I'm aware I
need to use the FireEvent command to trigger an event, but I was having
trouble even connecting to the object, let alone triggering or catching an
event. Anyway now it all seems to be working.

Please let me know if you would like more information,
Joe Marriott

"mr_unreliable" <kindlyReplyToNewsgroup(a)notmail.com> wrote in message
news:OwnWOJarFHA.3604(a)tk2msftngp13.phx.gbl...
> Joe, I am answering the question that you didn't ask.
>
> You are not going to get any "TestEvent" events, because
> you don't use "FireEvent" anywhere in your component.
>
> I suggest re-reading this page in your wsc doc:
>
> "Exposing Custom Events in Behavior Script Components"
>
> As to the "can't connect" error, that usually means that
> the component is not registered properly, (even though
> you are asserting that it was)...
>
> cheers, jw
> ____________________________________________________________
>
> You got questions? WE GOT ANSWERS!!! ..(but,
> no guarantee the answers will be applicable to the questions)
>
>
> Joe Marriott wrote:
>> Can someone help me connect to a WSC with an event sink?
>>


From: mr_unreliable on
if you're happy, i'm happy.

cheers, jw

Joe Marriott wrote:
> Please let me know if you would like more information,
> Joe Marriott
 | 
Pages: 1
Prev: RUNAS+.exe
Next: Wake on LAN