我給你我的工作示例,你使用process
類使用Async
事件,這樣你就可以得到輸出數據和錯誤。
Dim Proceso As New Process
'Register Output async event
AddHandler Proceso.OutputDataReceived, AddressOf CallbackProcesoAsync
'Register error output async event
AddHandler Proceso.ErrorDataReceived, AddressOf ErrorDataReceivedAsync
Dim startInfo As New ProcessStartInfo
startInfo.FileName = execFile
startInfo.Arguments = CmdExeArguments
startInfo.ErrorDialog = False
startInfo.UseShellExecute = False
Private Sub CallbackProcesoAsync(sender As Object, args As System.Diagnostics.DataReceivedEventArgs)
If Not args.Data Is Nothing AndAlso Not String.IsNullOrEmpty(args.Data) Then
'Do stuff with your output results
End If
End Sub
Private Sub CallbackProcesoAsync(sender As Object, args As System.Diagnostics.DataReceivedEventArgs)
If Not args.Data Is Nothing AndAlso Not String.IsNullOrEmpty(args.Data) Then
'Do stuff with error output
End If
End Sub
是不是有一個小命令可以簡單地顯示在VB6頁(panal)上的控制檯? ==>就像我們可以在對話框中顯示Excel表格一樣 –