參考引用:
--
Try
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
With Process1
.StartInfo.FileName = "cmd.exe"
.StartInfo.UseShellExecute = False
.StartInfo.RedirectStandardInput = True
.StartInfo.RedirectStandardOutput = True
.StartInfo.RedirectStandardError = True
.StartInfo.CreateNoWindow = True
.Start()
.StandardInput.WriteLine(TextBox1.Text.Trim)
.StandardInput.WriteLine("exit")
RichTextBox1.Text = .StandardOutput.ReadToEnd + .StandardError.ReadToEnd
End With
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = ""
RichTextBox1.Text = ""
End Sub
Catch
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
With Process1
.StartInfo.FileName = "commnad.com"
.StartInfo.UseShellExecute = False
.StartInfo.RedirectStandardInput = True
.StartInfo.RedirectStandardOutput = True
.StartInfo.RedirectStandardError = True
.StartInfo.CreateNoWindow = True
.Start()
.StandardInput.WriteLine(TextBox1.Text.Trim)
.StandardInput.WriteLine("exit")
RichTextBox1.Text = .StandardOutput.ReadToEnd + .StandardError.ReadToEnd
End With
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = ""
RichTextBox1.Text = ""
End Sub
End Try
沒有留言:
張貼留言