EDN Admin
Well-known member
So I recently got sorted out being able to send a cmd.exe function from a button and have the output show up in a text box. The problem that exists now is that if I insert a function that loops the application never returns the output because its coded to
output to the text box only after the function has completed is process. For example, if I wanted to use ping -t google.com I would never receive the output because the process doesnt complete. How can I stream to this text box instead of only getting output
after its completed the process.
The code I am using for a button is
<pre class="lang-vb prettyprint
Thanks for any help! Steve
[/code]
View the full article
output to the text box only after the function has completed is process. For example, if I wanted to use ping -t google.com I would never receive the output because the process doesnt complete. How can I stream to this text box instead of only getting output
after its completed the process.
The code I am using for a button is
<pre class="lang-vb prettyprint
Code:
<span class="kwd Dim<span class="pln myProcess <span class="kwd As<span class="pln Process <span class="pun =<span class="pln <span class="kwd New<span class="pln Process<br/><span class="kwd Dim<span class="pln s <span class="kwd As<span class="pln <span class="kwd String<span class="pln <br/>myProcess<span class="pun .<span class="pln StartInfo<span class="pun .<span class="pln FileName <span class="pun =<span class="pln <span class="str "c:windowssystem32cmd.exe"<span class="pln <br/>myProcess<span class="pun .<span class="pln StartInfo<span class="pun .<span class="pln UseShellExecute <span class="pun =<span class="pln <span class="lit False<span class="pln <br/>myProcess<span class="pun .<span class="pln StartInfo<span class="pun .<span class="pln CreateNoWindow <span class="pun =<span class="pln <span class="lit True<span class="pln <br/>myProcess<span class="pun .<span class="pln StartInfo<span class="pun .<span class="pln RedirectStandardInput <span class="pun =<span class="pln <span class="lit True<span class="pln <br/>myProcess<span class="pun .<span class="pln StartInfo<span class="pun .<span class="pln RedirectStandardOutput <span class="pun =<span class="pln <span class="lit True<span class="pln <br/>myProcess<span class="pun .<span class="pln StartInfo<span class="pun .<span class="pln RedirectStandardError <span class="pun =<span class="pln <span class="lit True<span class="pln <br/>myProcess<span class="pun .<span class="pln Start<span class="pun ()<span class="pln <br/><br/><span class="kwd Dim<span class="pln sIn <span class="kwd As<span class="pln System<span class="pun .<span class="pln IO<span class="pun .<span class="pln StreamWriter <span class="pun =<span class="pln myProcess<span class="pun .<span class="pln StandardInput<br/><span class="kwd Dim<span class="pln sOut <span class="kwd As<span class="pln System<span class="pun .<span class="pln IO<span class="pun .<span class="pln StreamReader <span class="pun =<span class="pln myProcess<span class="pun .<span class="pln StandardOutput<br/><span class="kwd Dim<span class="pln sErr <span class="kwd As<span class="pln System<span class="pun .<span class="pln IO<span class="pun .<span class="pln StreamReader <span class="pun =<span class="pln myProcess<span class="pun .<span class="pln StandardError<br/><br/>sIn<span class="pun .<span class="pln AutoFlush <span class="pun =<span class="pln <span class="lit True<span class="pln <br/>sIn<span class="pun .<span class="pln Write<span class="pun (<span class="str "ping -t google.com"<span class="pln <span class="pun &<span class="pln System<span class="pun .<span class="pln Environment<span class="pun .<span class="pln NewLine<span class="pun )<span class="pln <br/>sIn<span class="pun .<span class="pln Write<span class="pun (<span class="str "exit"<span class="pln <span class="pun &<span class="pln System<span class="pun .<span class="pln Environment<span class="pun .<span class="pln NewLine<span class="pun )<span class="pln <br/>s <span class="pun =<span class="pln sOut<span class="pun .<span class="pln ReadToEnd<span class="pun ()<span class="pln <br/><br/><span class="kwd If<span class="pln <span class="kwd Not<span class="pln myProcess<span class="pun .<span class="pln HasExited <span class="kwd Then<span class="pln <br/> myProcess<span class="pun .<span class="pln Kill<span class="pun ()<span class="pln <br/><span class="kwd End<span class="pln <span class="kwd If<span class="pln <br/>cmdOutputTextBox<span class="pun .<span class="pln Text <span class="pun =<span class="pln s<br/>cmdOutputTextBox<span class="pun .<span class="pln Visible <span class="pun =<span class="pln <span class="lit True<span class="pln <br/>sIn<span class="pun .<span class="pln Close<span class="pun ()<span class="pln <br/>sOut<span class="pun .<span class="pln Close<span class="pun ()<span class="pln <br/>sErr<span class="pun .<span class="pln Close<span class="pun ()<span class="pln <br/>myProcess<span class="pun .<span class="pln Close<span class="pun ()<span class="pln
Code:
<span class="pln <br/>
View the full article