我需要使用的应用程序(USB捕获实用程序)有一个.cmd版本,我可以从我的Visual Basic代码调用。我能够启动应用程序并将其置于“命令行模式”,如下所示:
Public Class MyClass
Dim StreamWriteUtility As System.IO.StreamWriter
Dim StreamReadUtility As System.IO.StringReader
Dim ProcessInfo As ProcessStartInfo
Dim Process As Process
Public Sub StartUSBCapture(ByVal DataStorageLocation As String)
Dim ProcessInfo As ProcessStartInfo
Dim Process As New Process
ProcessInfo = New ProcessStartInfo("C:\FW_Qualification_Suite\data-center-windows\data-center\bin\datacenter.cmd", "-c ")
ProcessInfo.CreateNoWindow = True
ProcessInfo.UseShellExecute = False 'Must be changed if redirect set to True
ProcessInfo.RedirectStandardInput = True
Process = Process.Start(ProcessInfo)
SWUtility = Process.StandardInput
While True
SWUtility.WriteLine("run") 'Looping for test to ensure this isn't a timing issue
End While
End Sub
End Class
这将启动应用程序并打开一个单独的命令行窗口,该窗口应接受更多命令(即捕获,运行,停止等)。但是,我无法在命令行窗口中显示这些后续命令。我已经尝试重定向过程的标准输入,但仍然没有显示在控制台窗口中。
有人能说出我应该如何将这些命令从我的Visual Basic程序中提取到这个应用程序中吗?