Here's a KB article on how to do this with straight API calls:
Q171654 - HOWTO: Attach a Console Window to Your Visual Basic Program
http://support.microsoft.com/support/kb/articles/Q171/6/54.asp
There's also an undocumented (but supported - it was just supposed to be hidden ;-)
GetStandardStream method (FSO).
Jeff Mastry posted the following VB6 example earlier this year (February) that uses
GetStandardStream()...
Private Sub Form_Load()
If AllocConsole() Then
hConsole = GetStdHandle(STD_OUTPUT_HANDLE)
If hConsole = 0 Then MsgBox "Couldn't allocate STDOUT"
Dim fso As New FileSystemObject
Dim out As TextStream
Set out = fso.GetStandardStream(1)
out.Write "This is a test!" & vbCrLf
out.Close
Else
MsgBox "Couldn't allocate console"
End If
End Sub
--
Michael Harris
MVP Scripting
Michael,
I see that you're right.
I was hoping to be able to access stdin and stdout from a VB app, but it
looks like they're only available when running cscript from the command
line. I don't see them in the object browser. :-(
Thanks for the help.
Peter Young
Quote:
> The descriptive text in the typelib (embedded in wshom.ocx) is incorrect.
It stills says "Windows
Quote:
> Script Host Object Model (Ver 1.0)" even for the wshom.ocx that has a
binary version of 5.1 (WSH
Quote:
> 2.0).
> The typelib description for wscript.exe is correct - "Windows Script Host
(Ver 5.1)"...
> --
> Michael Harris
> MVP Scripting