Hello,

I have to use some vbs script, lauching them from within another
application i'm coding in err ... another language :)

Is there a simple way to force redirection of STDOUT and STDERR from
within the vbs script ?

That is I'm looking for some instructions to add at the begining of the
vbs script, that will take 2 filenames as arguments and afterwards
redirect the stderr and stdout to these files.

The point here is that i do not want to use some command line
redirection . Also, i do not want to mess with the rest of the script,
i just want the standard streams to be redirected.

I have zero vbs knowledge so i really do not know if this question is
stupid or if it's even possible.
Thanks a lot if someone can help,
Dav'

Re: STDERR and STDOUT redirection from within a vbs script by Steve

Steve
Fri Jan 28 08:29:43 CST 2005

wrote:

> Hello,
>
> I have to use some vbs script, lauching them from within another
> application i'm coding in err ... another language :)
>
> Is there a simple way to force redirection of STDOUT and STDERR from
> within the vbs script ?
>
> That is I'm looking for some instructions to add at the begining of the
> vbs script, that will take 2 filenames as arguments and afterwards
> redirect the stderr and stdout to these files.
>
> The point here is that i do not want to use some command line
> redirection . Also, i do not want to mess with the rest of the script,
> i just want the standard streams to be redirected.

What you want probably can't be done.

The only way to redirect the streams without command line redirection or
changing the script would involve invoking the script with some host method
similar to WshShell.Exec that captures them itself. Since you don't say
what host you're using, we can't say if this is possible.

Changing the script involves hooking file handles into either the StdOut
and StdErr streams or text files:

Set FSO = CreateObject("Scripting.FileSystemObject")
Set Args = WScript.Arguments
If Args.Count = 0 Then
Set MyStdOut = WScript.StdOut
Else
' You probably want more robust error handling here ;-)
Set MyStdOut = FSO.OpenTextFile(Args.Item(0),2,True)
End If

' Use MyStdOut instead of WScript.StdOut
MyStdOut.WriteLine "Hello, World!"

And, of course, there's command line redirection.

--
Steve

The most perfect technique is that which is not noticed at all.
-Pablo Casals

Re: STDERR and STDOUT redirection from within a vbs script by dcd

dcd
Tue Feb 01 10:32:42 CST 2005

Thanks for this clarification !
It seems indeed to "vbscript-ish" for me and i will therefore use
command line redirection ...
As a note, i don't know <I>myself</I> what host i'm using , i don't
think i know what "host" means in this context !


Re: STDERR and STDOUT redirection from within a vbs script by dcd

dcd
Tue Feb 01 10:32:58 CST 2005

Thanks for this clarification !
It seems indeed to "vbscript-ish" for me and i will therefore use
command line redirection ...
As a note, i don't know myself what host i'm using , i don't think i
know what "host" means in this context !