Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 410527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:53:50+00:00 2026-05-12T17:53:50+00:00

I’ve been searching around the net for roughly three hours now w/o getting forward.

  • 0

I’ve been searching around the net for roughly three hours now w/o getting forward. I don’t know VB very well, but I need to create a wrapper program for any executable that logs the arguments, all input, output and err information:

  • My wrapper is called: e.g. someApp.exe arg1 arg2
  • Logs to someApp.log: arg1 arg2
  • Calls original executable: _someApp.exe arg1 arg2
  • Must log and forward any console input to _someApp process inputstream
  • Must log any output and error stream from _someApp process

Okay, I’m stuck at point 4 now:

        Dim p As New ProcessStartInfo
        p.FileName = execute
        p.Arguments = Command()
        p.UseShellExecute = False
        p.CreateNoWindow = True
        p.RedirectStandardInput = True
        p.RedirectStandardError = True
        p.RedirectStandardOutput = True

        Dim process As System.Diagnostics.Process
        process = Diagnostics.Process.Start(p)
        process.WaitForExit()

After _someApp ends I am able to read out and err stream to log it, but I still need to provide my own wrappers input to the process and I want to read out and err stream as it happens.

Thanks for info/examples

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T17:53:50+00:00Added an answer on May 12, 2026 at 5:53 pm

    Okay here the solution…

    Variables needed:

    Private process As System.Diagnostics.Process
    
    Private threadOut As Thread
    
    Private streamOut As System.IO.StreamReader
    
    Private threadErr As Thread
    
    Private streamErr As System.IO.StreamReader
    
    Private threadIn As Thread
    
    Private streamIn As System.IO.StreamWriter
    

    Subs needed:

    Private Sub ThreadTaskOut()
        Dim line
        While Not process.HasExited
            line = streamOut.ReadToEnd
            If line <> Nothing And line <> "" Then
                log("Out: " & line)
                Console.Out.Write(line)
            End If
        End While
    End Sub
    
    Private Sub ThreadTaskErr()
        Dim line
        While Not process.HasExited
            line = streamErr.ReadToEnd
            If line <> Nothing And line <> "" Then
                log("Err: " & line)
                Console.Error.Write(line)
            End If
        End While
    End Sub
    
    Private Sub ThreadTaskIn()
        Dim line
        While Not process.HasExited
            line = Console.In.ReadLine
            If line <> Nothing And line <> "" Then
                log("In: " & line)
                streamIn.WriteLine(line)
            End If
        End While
    End Sub
    

    Inside main:

            ' create process information
            Dim p As New ProcessStartInfo
            p.FileName = execute
            p.Arguments = Command()
            p.UseShellExecute = False
            p.CreateNoWindow = True
            p.RedirectStandardInput = True
            p.RedirectStandardError = True
            p.RedirectStandardOutput = True
    
            ' log process start
            log("Execute: " & execute & " " & Command())
    
            ' start process
            process = Diagnostics.Process.Start(p)
    
            ' start thread for output stream
            streamOut = process.StandardOutput
            threadOut = New Thread(AddressOf ThreadTaskOut)
            threadOut.IsBackground = True
            threadOut.Start()
    
            ' start thread for error stream
            streamErr = process.StandardError
            threadErr = New Thread(AddressOf ThreadTaskErr)
            threadErr.IsBackground = True
            threadErr.Start()
    
            ' start thread for input stream
            streamIn = process.StandardInput
            threadIn = New Thread(AddressOf ThreadTaskIn)
            threadIn.IsBackground = True
            threadIn.Start()
    
            ' wait for the process to finish
            process.WaitForExit()
    

    log is another sub to log to file, execute is the variable holding the _someApp.exe frommy initial post. I still don’t know if the console to inputstream thread dows it right, because my wrapped app had no input as it seems. May someone spotts an error…

    For my purposes, hmm it works like I need it

    Greetz,
    GHad

    Code inside main

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.