我知道如何通过startinfo.arguments
将参数发送到子程序。我想我甚至知道如何“倾听”孩子可能通过standardoutput.readline
“说”的任何事情。我不知道的是用什么方法让孩子“说话”回父母。这是我到目前为止的代码(在父方面):
Dim proc As Process
Dim bRunProgramWorked As Boolean = True
Try
proc = New Process
Dim procInfo As New ProcessStartInfo
proc.StartInfo.FileName = strPathUpgradeEXE
proc.StartInfo.Arguments = param1 & " " & param2 & " " & param3
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
'proc.StartInfo.WindowStyle = ProcessWindowStyle.Maximized
proc.StartInfo.UseShellExecute = False
proc.StartInfo.CreateNoWindow = True
proc.StartInfo.RedirectStandardOutput = True
'proc.StartInfo.RedirectStandardError = True
proc.Start()
Dim output1 As String = proc.StandardOutput.ReadLine
Dim output2 As String = proc.StandardOutput.ReadLine
proc.WaitForExit()
proc.Close()
proc.Dispose()
Catch ex As Exception
LogIt(strMyBaseID, "Error at trying to run PVT-Export. " & ex.ToString)
bRunProgramWorked = False
End Try
答案 0 :(得分:2)
子进程需要写入Console.Out
。