我有以下代码来启动程序R(尽管我认为该程序与此处的问题无关)并运行脚本:
Public Shared Sub RunRScript(rCodeFilePath As String, rScriptExecutablePath As String, args As String)
Dim file As String = rCodeFilePath
Dim result As String = String.Empty
Try
Dim info = New ProcessStartInfo()
info.FileName = rScriptExecutablePath
info.WorkingDirectory = Path.GetDirectoryName(rScriptExecutablePath)
info.Arguments = rCodeFilePath & " " & args
info.RedirectStandardInput = False
info.RedirectStandardOutput = True
info.UseShellExecute = False
info.CreateNoWindow = True
Using proc = New Process()
proc.StartInfo = info
proc.Start()
result = proc.StandardOutput.ReadToEnd()
proc.Close()
End Using
Catch ex As Exception
Throw New Exception("R Script failed: " & result, ex)
End Try
End Sub
问题是,如果我在R中运行的脚本中出现错误,则不会收到错误消息,因为该实例是不可见的。我尝试用
显示它.WindowStyle = ProcessWindowStyle.Normal
<。>在.UseShellExcecute和.CreateNoWindow的所有组合中,但这不起作用。任何人都可以帮助我使我的过程可见吗?