Results 1 to 2 of 2

Thread: How to read the standard output during runtime?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2009
    Posts
    128

    How to read the standard output during runtime?

    Hello all,
    I need your advice please:

    I execute shell command that can take up to 5 minutes. This command command writes to standard output during its running.
    I'm using this way:

    Code:
    With CreateObject("wscript.shell")
                AllocConsole
                ShowWindow GetConsoleWindow, SW_HIDE
                
                commandExec = "cmd /c blahblah"
                With .exec(commandExec)
                
                    line = .stdout.readall
    end with
    My question: How can I read the standard output during it's running? As you can see, I get the standard out AFTER the "cmd /c" execution is finished (5 minutes....). I'd like to see it and display it in REAL time.
    I'd like to show it to users just as the output is updated (like UNIX "tail" command), so if you know a good way to implement this also, it will be very appreciated.

    Thanks in advance!

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: How to read the standard output during runtime?

    vb Code:
    1. With .StdOut
    2.             If Not .AtEndOfStream Then
    3.                 DoEvents
    4.                 Text1.SelStart = Len(Text1.Text)
    5.                 Text1.SelText = .ReadAll()
    6.             End If
    7.         End With
    or keep adding to str variable
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width