这里就给出基于VB.net的核心代码:
引用:
Dim myProcess As New Process()
Dim myProcessStartInfo As New ProcessStartInfo("cmd.exe")
myProcessStartInfo.UseShellExecute = False
myProcessStartInfo.RedirectStandardOutput = true
myProcess.StartInfo = myProcessStartInfo
myProcessStartInfo.Arguments="/c " & Cmd.text
myProcess.Start()
Dim myStreamReader As StreamReader = myProcess.StandardOutput
Dim myString As String = myStreamReader.Readtoend()
myProcess.Close()
result.text=Cmd.text & vbcrlf & "" & mystring & "
"
这里是利用了New ProcessStartInfo类,具体请参考.net文档