shell,console and standard input and output

C

Christophe HELFER

Hi,

I would like to do this in VB Languague.

I have an executable file in DOS mode. This executable returns informations
and display them to the DOS window. Unfortunately, I have to process theses
informations.
The way to do that, is to redirect standard input and output, insn't it ?
This is possible in C++ language, but I cannot make any line in this
language.

Then I have tried with the Console class but this class don't execute
programs like the Shell() function ! The line I tried is :
console.write("Exename") and with the Console.read () method, I obtain no
data !

Can anyone tell me if I did wrong, or if it's simply possible !

thanks for your help
 
C

Cor

Hi Chrisophe,

Why not write it to disk and than read it back, more simple I cannot
imaging?

Just my thought.

Cor
 
C

Christophe HELFER

Because this program is interactive like ftp in DOS mode, you have to put
commands and then you get the response. This is unfeasible with external
file.
 
D

Dominique Vandensteen

more simple I cannot imaging?

I can :)

take a look at
System.Diagnostics.Process

look at the StandardOutput property
in the class reference you have an example how to get the process output
very easy


Dominique
 
C

Christophe HELFER

Thanks for your help, but perhaps I'm stupid.
I've tried with the ftp.exe as executable, so I can have interaction.
By trying this piece of code in a Console application, the variable strOut
is empty !



Sub Main()
Const Path = "C:\WINNT\System32\ftp.exe"

Const Args = "hostname"

Dim P As New Process

Dim strOut As String



P.StartInfo.UseShellExecute = False

P.StartInfo.RedirectStandardOutput = True

P.Start(Path, Args)

strOut = P.StandardOutput.ReadToEnd()

Debug.Write(strOut)

P.WaitForExit()

P.Close()

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top