Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Writing to Console (stdout) with VBScript from within the ScriptControl

18,847 views
Skip to first unread message

Julian Catchen

unread,
Feb 15, 2001, 4:03:28 PM2/15/01
to
Hi-

I am writing an application that uses the Microsoft Script Control to run
VBScripts. The VBScripts then interact with our internal data.

I want to write output, to the console the program is running in, from
within my script. If I run the following test script with the cscript.exe
program it works without a problem:

vbfoo
Sub vbfoo()
WScript.StdOut.Write "Hello World"
End Sub

However, when I fun the same script from within the ScriptControl, I get the
following error:

Object required: 'WScript'

Any ideas on how to write to StdOut from within the ScriptControl?


Michael Harris

unread,
Feb 16, 2001, 12:17:45 AM2/16/01
to
[FSO] GetStandardStream is supported but not in the official docs...

This was copy/pasted from a VB/VBA object browser...

================================================

Function GetStandardStream(StandardStreamType As StandardStreamTypes, [Unicode As Boolean]) As
TextStream
Member of IWshRuntimeLibrary.FileSystemObject

StandardStreamTypes
Const StdErr = 2
Const StdIn = 0
Const StdOut = 1


--
Michael Harris
Microsoft.MVP.Scripting
--
mik...@mvps.org
Please do not email questions - post them to the newsgroup instead.
--

"Julian Catchen" <julian.m...@intel.com> wrote in message news:96hg72$6...@news.or.intel.com...

Tom Lavedas

unread,
Feb 16, 2001, 10:34:02 AM2/16/01
to
Is this version dependent?

Tom Lavedas
-----------
http://www.pressroom.com/~tglbatch/

Julian Catchen

unread,
Feb 16, 2001, 11:04:38 AM2/16/01
to
Thanks for the help. Would it be possible for you to provide an example of
how to use this in VBScript? I am trying the following:

dim sout
set sout = GetStandardStream(StdOut)
sout.Write "Hello World"

But I keep getting type mismatch errors.

"Michael Harris" <mik...@mvps.org> wrote in message
news:ez0PMf9lAHA.2016@tkmsftngp02...

Tom Lavedas

unread,
Feb 16, 2001, 11:32:44 AM2/16/01
to
Just reading the info Michael posted, I think that should be ...

dim sout, oFS
const StdOut = 1
set oFS = CreateObject("Scripting.FileSystemObject")
set sout = oFS.GetStandardStream(StdOut)
sout.Write "Hello World"

I didn't take time to confirm this.

Julian Catchen

unread,
Feb 16, 2001, 11:43:39 AM2/16/01
to
Great! It works! Thanks for the help.

"Tom Lavedas" <lav...@pressroom.com> wrote in message
news:3A8D562C...@pressroom.com...

Michael Harris

unread,
Feb 16, 2001, 8:39:04 PM2/16/01
to
"Tom Lavedas" <lav...@pressroom.com> wrote in message news:3A8D486A...@pressroom.com...
> Is this version dependent?
>

scrrun 5.1.x.x or higher (i.e., WSH 2.0+)

0 new messages