How to put shell output into a textbox

F

Franky

Got this from the Internet. Almost what I need except instead of putting the
data into a file I'd like it to go into a TextBox.



Can someone show me how to do that



thanks



pi.RedirectStandardOutput = True

pi.FileName = .FileName

pi.UseShellExecute = False

Dim sw As New System.IO.StreamWriter("C:\OutPut.txt")

p = Process.Start(pi)

sw.WriteLine(p.StandardOutput.ReadToEnd)

p.WaitForExit()

sw.Close()
 
H

Herfried K. Wagner [MVP]

Franky said:
Got this from the Internet. Almost what I need except instead of putting
the data into a file I'd like it to go into a TextBox.
[...]
pi.RedirectStandardOutput = True

pi.FileName = .FileName

pi.UseShellExecute = False

Line of code removed here.
p = Process.Start(pi)

Line of code altered here:

\\\
Me.TextBox1.Text = p.StandardOutput.ReadToEnd()
///
 
F

Franky

so easy when you know how

thanks

Herfried K. Wagner said:
Franky said:
Got this from the Internet. Almost what I need except instead of putting
the data into a file I'd like it to go into a TextBox.
[...]
pi.RedirectStandardOutput = True

pi.FileName = .FileName

pi.UseShellExecute = False

Line of code removed here.
p = Process.Start(pi)

Line of code altered here:

\\\
Me.TextBox1.Text = p.StandardOutput.ReadToEnd()
///
p.WaitForExit()

sw.Close()
 
F

Franky

I noticed you used "Me" below. I like that and wish there is a switch that
tells the compiler that it is never to be assumed - that is, catch me when I
don't use it.

Is there such an option?

Thanks


Herfried K. Wagner said:
Franky said:
Got this from the Internet. Almost what I need except instead of putting
the data into a file I'd like it to go into a TextBox.
[...]
pi.RedirectStandardOutput = True

pi.FileName = .FileName

pi.UseShellExecute = False

Line of code removed here.
p = Process.Start(pi)

Line of code altered here:

\\\
Me.TextBox1.Text = p.StandardOutput.ReadToEnd()
///
p.WaitForExit()

sw.Close()
 
H

Herfried K. Wagner [MVP]

Franky said:
I noticed you used "Me" below. I like that and wish there is a switch that
tells the compiler that it is never to be assumed - that is, catch me when
I don't use it.

Is there such an option?

No. I use 'Me.' only to get an appropriate IntelliSense selection list when
writing code.
 
F

Franky

Thanks



One more question.

The following does not work

Can you tell me what does

pi.FileName = "%SystemRoot%\shell32\cmd.exe"
 
H

Herfried K. Wagner [MVP]

Franky said:
The following does not work

Can you tell me what does

pi.FileName = "%SystemRoot%\shell32\cmd.exe"

On my machine no such path exists. In addition you may want to check the
environment variable-related methods of the 'System.Environment' class which
can be used to expand environment variables inside strings representing a
path. However, 'pi.FileName = "cmd.exe"' should be sufficient.
 

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