Process Class hangs

  • Thread starter Thread starter Blaz Ziherl
  • Start date Start date
B

Blaz Ziherl

I want to pass DOS commands to cmd.exe using Process class. I have one
textbox for writing the input commands and another for displaying
results. However, whenever I call ReadToEnd method of the StreamReader
that reads process StandardOutput, the whole thing hangs, unless I call
"exit" command before that.

I'd like to make an utility where you could write your dos commands in
one textbox and get results in another.

How can I send multiple commands to cmd.exe process, without exiting it
each time?
 
The ProcessInfoClass has an ARGUMENTS keyword you can use for your command
line switches...

Is the console still writing to the file you are trying to read at the time
you are trying to read it?
 
Blaz,

In my opinion is this one working. (it is not using the peek)

\\\
Dim p As New Process
dim pi as new processstartinfo
pi.UseShellExecute = False
pi.RedirectStandardOutput = True
pi.Arguments = myargumentstring
pi.WorkingDirectory = myworkdirectorystring
pi..FileName =C:\myprogram
pi.startinfo = pi
p.Start()
Dim sr As IO.StreamReader = p.StandardOutput
Dim sb As New System.Text.StringBuilder("")
Dim input As Integer = sr.Read
Do Until input = -1
sb.Append(ChrW(input))
input = sr.Read
Loop
///

I hope this helps,

Cor
 
Thank you all very much! I have solved my problem with your help now.
Thanks again!

Regards,
Blaz
 

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

Back
Top