Link to home
Start Free TrialLog in
Avatar of andieje
andieje

asked on

running an executable program from vb.net 2005

Hello

I have a vb.net program and I would like it to run an executable. It's a perl program and it sends any error message to standard error which seems to mean when i run it at a command prompt it prints the messages at the console window.

How would i run this program from within vb.net and and catch its error messages.

Many thanks
andrea
Avatar of DjDezmond
DjDezmond
Flag of United Kingdom of Great Britain and Northern Ireland image

Redirecting process outputs and so forth... pretty interesting actually. might have a blast on one of my own projects...

http://www.security-forums.com/viewtopic.php?t=43234&sid=bd37faf6dbbe04d5f52c631182bb7ede

Dez
ASKER CERTIFIED SOLUTION
Avatar of DjDezmond
DjDezmond
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I havent checked the link above but herez the code that I use in one of my programs :

            Dim pWinRar As Process = System.Diagnostics.Process.Start(m_WinRARpath, strParam)
            Application.DoEvents()
            pWinRar.WaitForExit()
            intExitCode = pWinRar.ExitCode
Avatar of andieje
andieje

ASKER

Hello

That's great - thanks very much.

A couple of questions:

1. How do i access any error message produced from the program. I can see that you create an input stream on the standard error but its never used. Would you just call the readtoend method on the error stream like you do with the input stream.

2. Is there any way to access the errors in the error stream as they happen. I'm not sure if i need to do this as it's not like i can interact with the program when it reports an error message but it feels like it might be a useful thing to know

thanks a lot
andrea
Theres two output streams taken in the code i've posted. If the errors aren't part of the standard error stream then i would assume they would be sent down the standard output pipe.

I've not really played with this code, but im sure you could execute a loop on a seperate thread to constantly read to the end of each stream and raise and event when new data (possibly your error) is 'received'?

Dez
Avatar of andieje

ASKER

Thank-you very much