关于 ProcessStartInfo 的使用,如果显示被调用exe的输出信息?
现在有一个exe,
比如叫XX.exe,这个exe是现成的,没有源代码。
通过使用的时候,
通过dos窗口,直接调用的话,
这个XX.exe在执行的过程中,会输出一些信息。
现在,我想给这个XX.exe做了一个壳,加一些执行前的check。
这个壳执行XX.exe时,新开,或者不新开窗口均可。
问题出在,如何才能保证XX.exe原有的输出信息,都正常输出,能被用户正常看到?
代码如果写成这样的话,会新开一个新窗口,
在新窗口中,能正常输出XX.exe的输出信息,但是执行完,还没等看清楚,窗口立马就关掉了。
有什么办法,不让弹出的这个窗口关掉么?
Dim p As Process = New Process()
Dim startInfo As New ProcessStartInfo()
startInfo.FileName = "H:\XX.exe"
startInfo.Arguments = My.Application.CommandLineArgs(0)
p.StartInfo = startInfo
p.Start()
p.WaitForExit()
p.Close()
我要是加上下面这些代码的话,不会创建新窗口,
但是XX.exe很明显没有被调用起来。
startInfo.UseShellExecute = False '不使用系统外壳程序启动
startInfo.RedirectStandardInput = False '不重定向输入
startInfo.RedirectStandardOutput = true '重定向输出
startInfo.CreateNoWindow = False '不创建窗口
这样的问题,有什么好的解决方法么?