3
Contributors
2
Replies
3
Views
13 Years
Discussion Span
Last Post by cypher
0

how about something like this...

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Const SW_HIDE = 0

Private Sub Command1_Click()
Open "C:\test.bat" For Output As #1
Print #1, "net session > view.txt"
Close #1

ShellExecute Me.hwnd, "open", "test.bat", "", "C:\", SW_HIDE
Sleep 20 ' wait for file to get created!!!
Open "C:\view.txt" For Input As #1
Text1.Text = ""
Do Until EOF(1)
Line Input #1, fdata$
Text1.Text = Text1.Text + fdata$ + vbNewLine
Loop

Close #1

Kill "C:\view.txt"

End Sub

0

The only way I know of off hand is to use API to define a process, hook into it, and set its STDOUT to a stream, that you can read. That would take a WHOLE lot of API programming, and is likely not going to be an acceptible answer for a VB programmer (it wouldn't be for me).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.