Hello, I'm trying to embed command prompt to my app. The output textbox is freezing when I run the program. Actually it isn't freezing, it's waiting exe to finish its work. I want to get lines immediately as it does in command prompt.
vb.net Code:
Private Sub CMDAutomate() Dim cmdProcess As New Process Dim StartInfo As New System.Diagnostics.ProcessStartInfo StartInfo.FileName = "anexecutable" 'starts cmd window StartInfo.Arguments = "somearguments" StartInfo.RedirectStandardInput = True StartInfo.RedirectStandardOutput = True StartInfo.UseShellExecute = False 'required to redirect StartInfo.CreateNoWindow = True 'creates no cmd window cmdProcess.StartInfo = StartInfo cmdProcess.Start() Dim SR As System.IO.StreamReader = cmdProcess.StandardOutput Dim SW As System.IO.StreamWriter = cmdProcess.StandardInput SW.WriteLine(OutputTextBox.Text) 'the command you wish to run..... SW.WriteLine("exit") 'exits command prompt window Results = SR.ReadToEnd 'returns results of the command window SW.Close() SR.Close() 'invokes Finished delegate, which updates textbox with the results text Invoke(Finished) End Sub
By the way, (I don't know where to ask) how can I wrap my codes in this site with vb.net style?




Reply With Quote
