Home All Groups Group Topic Archive Search About

How to put shell output into a textbox

Author
17 Dec 2006 2:04 AM
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()

Author
17 Dec 2006 2:10 AM
Herfried K. Wagner [MVP]
" Franky" <frankieNOSPAM@a-znet.com> schrieb:
> 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()
///

Show quoteHide quote
> p.WaitForExit()
>
> sw.Close()

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
17 Dec 2006 4:56 PM
Franky
so easy when you know how

thanks

Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:%23BC39BYIHHA.5000@TK2MSFTNGP03.phx.gbl...
>" Franky" <frankieNOSPAM@a-znet.com> schrieb:
>> 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()
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
17 Dec 2006 5:11 PM
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


Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:%23BC39BYIHHA.5000@TK2MSFTNGP03.phx.gbl...
>" Franky" <frankieNOSPAM@a-znet.com> schrieb:
>> 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()
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
17 Dec 2006 5:18 PM
Herfried K. Wagner [MVP]
" Franky" <frankieNOSPAM@a-znet.com> schrieb:
>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.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
17 Dec 2006 6:44 PM
Franky
Thanks



One more question.

The following does not work

Can you tell me what does

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

Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:eoPmU9fIHHA.4112@TK2MSFTNGP04.phx.gbl...
>" Franky" <frankieNOSPAM@a-znet.com> schrieb:
>>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.
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
17 Dec 2006 7:55 PM
Herfried K. Wagner [MVP]
" Franky" <frankieNOSPAM@a-znet.com> schrieb:
> 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.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>