From: Saran on
Hello. I'm trying to use sockets in vbscript, but I get the feeling I
need to install something.

test.vbs
----------
SET Test = CreateObject("MSWinsock.Winsock", "TEST_")

SUB Test_Connect()
msgBox "Test::Connected"
END SUB
----------


Gives:
----------
C:\test>cscript test.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

C:\test\test.vbs(1, 1) Microsoft VBScript runtime error: The remote
server machine does not exist or is unavailable: 'CreateObject'
----------


If I use WScript.CreateObject instead of just CreateObject by itself, I
get this error instead:
----------
C:\test\test.vbs(1, 1) WScript.CreateObject: Could not create object
named "MSWinsock.Winsock".
----------

Though things like
SET MyHashTable1 = CreateObject("Scripting.Dictionary")
SET MyHashTable2 = WScript.CreateObject("Scripting.Dictionary")
work just fine.
(BTW is there a difference between using WScript and leaving it off?)

I'm running Win XP SP2, WSH 5.6, Visual Studio (.Net Pro 2003 and 6.0
Ent.)

Is there something I need to download/install ?

Thanks for any help.


From: mr_unreliable on
hi Saran,

I don't have msWinsock either. I am guessing that it's one
of those controls distributed with the professional version
of visual basic, rather than with the win system.

However, all is not lost. You can find it on the web, as
part of the distribution of any vb app the needs it to run.

In addition, there are some sites that specialize in offering
downloads of "missing" dll's, ocx's, etc.

One such site, which apparently has msWinsock.ocx is:

http://www.vbcodesource.com/control.html

cheers, jw
____________________________________________________________

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



Saran wrote:
> Hello. I'm trying to use sockets in vbscript, but I get the feeling I
> need to install something.
>
> test.vbs
> ----------
> SET Test = CreateObject("MSWinsock.Winsock", "TEST_")
>
> SUB Test_Connect()
> msgBox "Test::Connected"
> END SUB
> ----------
>
>
> Gives:
> ----------
> C:\test>cscript test.vbs
> Microsoft (R) Windows Script Host Version 5.6
> Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
>
> C:\test\test.vbs(1, 1) Microsoft VBScript runtime error: The remote
> server machine does not exist or is unavailable: 'CreateObject'
> ----------
>
>
> If I use WScript.CreateObject instead of just CreateObject by itself, I
> get this error instead:
> ----------
> C:\test\test.vbs(1, 1) WScript.CreateObject: Could not create object
> named "MSWinsock.Winsock".
> ----------
>
> Though things like
> SET MyHashTable1 = CreateObject("Scripting.Dictionary")
> SET MyHashTable2 = WScript.CreateObject("Scripting.Dictionary")
> work just fine.
> (BTW is there a difference between using WScript and leaving it off?)
>
> I'm running Win XP SP2, WSH 5.6, Visual Studio (.Net Pro 2003 and 6.0
> Ent.)
>
> Is there something I need to download/install ?
>
> Thanks for any help.
>
>
From: Saran on
Thank you. I already have a mswinsck.ocx in my windows\system32 folder.
Do I have to call it another way or am I still missing something?

As for "professional version of visual basic", I have both VB 6 (VS6
Ent) and VB.Net 2003 (VS 2003 Pro) installed.

mr_unreliable wrote:
> hi Saran,
>
> I don't have msWinsock either. I am guessing that it's one
> of those controls distributed with the professional version
> of visual basic, rather than with the win system.
>
> However, all is not lost. You can find it on the web, as
> part of the distribution of any vb app the needs it to run.
>
> In addition, there are some sites that specialize in offering
> downloads of "missing" dll's, ocx's, etc.
>
> One such site, which apparently has msWinsock.ocx is:
>
> http://www.vbcodesource.com/control.html
>
> cheers, jw
> ____________________________________________________________
>
> You got questions? WE GOT ANSWERS!!! ..(but,
> no guarantee the answers will be applicable to the questions)
>
>
>
> Saran wrote:
>> Hello. I'm trying to use sockets in vbscript, but I get the feeling I
>> need to install something.
>>
>> test.vbs
>> ----------
>> SET Test = CreateObject("MSWinsock.Winsock", "TEST_")
>>
>> SUB Test_Connect()
>> msgBox "Test::Connected"
>> END SUB
>> ----------
>>
>>
>> Gives:
>> ----------
>> C:\test>cscript test.vbs
>> Microsoft (R) Windows Script Host Version 5.6
>> Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
>>
>> C:\test\test.vbs(1, 1) Microsoft VBScript runtime error: The remote
>> server machine does not exist or is unavailable: 'CreateObject'
>> ----------
>>
>>
>> If I use WScript.CreateObject instead of just CreateObject by
>> itself, I get this error instead:
>> ----------
>> C:\test\test.vbs(1, 1) WScript.CreateObject: Could not create object
>> named "MSWinsock.Winsock".
>> ----------
>>
>> Though things like
>> SET MyHashTable1 = CreateObject("Scripting.Dictionary")
>> SET MyHashTable2 = WScript.CreateObject("Scripting.Dictionary")
>> work just fine.
>> (BTW is there a difference between using WScript and leaving it off?)
>>
>> I'm running Win XP SP2, WSH 5.6, Visual Studio (.Net Pro 2003 and 6.0
>> Ent.)
>>
>> Is there something I need to download/install ?
>>
>> Thanks for any help.


From: Shawn Fessenden on
> Hello. I'm trying to use sockets in vbscript

Me too. You probably have exactly the same problem I do. The events are not
"connected" to the object, even though they ought to be. Let me know if you
figure it out & I'll do the same. Cheers.
-SHAWN-


From: Saran on
Christoph Basedau wrote:
> 19.11.2005 18:31, Saran schrieb:
>
>
>> Hello. I'm trying to use sockets in vbscript, but I get the feeling I
>> need to install something.
>>
>> test.vbs
>> ----------
>> SET Test = CreateObject("MSWinsock.Winsock", "TEST_")
>>
>> SUB Test_Connect()
>> msgBox "Test::Connected"
>> END SUB
>> ----------
>> error: The remote server machine does not exist or is unavailable:
>> 'CreateObject'
>
> The second param is optional and defines the remote machine where the
> component is installed. The error is reproducible, if there is no
> machine named 'TEST_'.

Thank you. Every example I found uses the 2nd param for defining the
event handler prefix, so now I'm confused.

>> If I use WScript.CreateObject instead of just CreateObject by
>> itself, I
>> get this error instead:
>> ----------
>> C:\test\test.vbs(1, 1) WScript.CreateObject: Could not create object
>> named "MSWinsock.Winsock".
>> ----------
>
> This should work on a developing machine with VS-6 installed.
> Check if the ocx is present and try to re-register the component:
>
> regsvr32 %WINDIR%\System32\MSWINSCK.OCX

Ran that, it still gives me the error.

Heres one of the exmaples I came across:

'----------- example.vbs -----------
Dim Raw
set Raw = WScript.CreateObject("MSWinsock.Winsock", "WSEvent_")
Raw.Connect "10.25.1.157" , 9100
msgbox "Running - close to continue"
Raw.Close

Sub WSEvent_Connect()
msgbox "Connected!"
end sub

Sub WSEvent_DataArrival(bytes)
MyString="blank"
Raw.GetData MyString
msgbox "data: "+CStr(bytes)+chr(13)+MyString
end sub
'-------------- End of Code ---------------------------------------


 |  Next  |  Last
Pages: 1 2
Prev: Registry permissions...
Next: Problem with copyhere