VB.NET 调用外部程序问题
Me.OpenFileDialog1.ShowDialog()
Dim j As String = OpenFileDialog1.FileName
Process.Start(j)
为什么我这样程序是可以调用EXE的,
Dim i As String = "D:\wanghc\调试中的程序\1exe\1exe\bin\Debug\Demo\OnlineFaceRec.exe"
Process.Start(i)
这样就不行了呢,程序一闪而过,我想不明白,用别的程序试是可以的,一开始我以为是那个EXE的问题,可是第一种方法还可以调用,请高手帮忙
[解决办法]
Public Function ExecuteCmd(ByVal cmd As String, ByVal CreateNoWindow As Boolean) Dim startInfo As New ProcessStartInfo("cmd.exe") '调用程序名 With startInfo .Arguments = "/C " + cmd '调用命令 CMD .RedirectStandardError = True .RedirectStandardOutput = True .UseShellExecute = False .CreateNoWindow = CreateNoWindow End With Dim p As Process = Process.Start(startInfo) Dim strOutput As String = p.StandardOutput.ReadToEnd() Dim strError As String = p.StandardError.ReadToEnd() p.WaitForExit() If (strOutput.Length <> 0) Then Return strOutput ElseIf (strError.Length <> 0) Then Return strError End If Return "" End Function