
这里主要用到了Process:代码如下
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MyProcess As New Process
With MyProcess.StartInfo
.FileName = "cmd.exe"
'关闭Shell的使用
.UseShellExecute = False
'重定向标准输入
.RedirectStandardInput = True
'生定向标准输出
.RedirectStandardOutput = True
'设置不显示窗体
.CreateNoWindow = True
'执行Dos命令
End With
MyProcess.Start()
MyProcess.StandardInput.WriteLine(Me.TextBox1.Text)
MyProcess.StandardInput.WriteLine("Exit")
'从输出流中获得命令执行结果
Me.TextBox2.Text = MyProcess.StandardOutput.ReadToEnd
End Sub
Dim MyProcess As New Process
With MyProcess.StartInfo
.FileName = "cmd.exe"
'关闭Shell的使用
.UseShellExecute = False
'重定向标准输入
.RedirectStandardInput = True
'生定向标准输出
.RedirectStandardOutput = True
'设置不显示窗体
.CreateNoWindow = True
'执行Dos命令
End With
MyProcess.Start()
MyProcess.StandardInput.WriteLine(Me.TextBox1.Text)
MyProcess.StandardInput.WriteLine("Exit")
'从输出流中获得命令执行结果
Me.TextBox2.Text = MyProcess.StandardOutput.ReadToEnd
End Sub
3074

被折叠的 条评论
为什么被折叠?



