我指的是这个问题: 在同一个控制台中启动一个进程
我在 unity3d 工作并尝试通过以下方式从 eclim 接收项目列表:
public static Process shell()
{
var pr = new Process();
pr.StartInfo = new ProcessStartInfo("\"C:/Program Files/eclipse_kepler/eclipse/eclim\"", "--nailgun-port 9091 -command projects"){
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardInput = true,
RedirectStandardError = true
};
UnityEngine.Debug.Log("attempting start with: "+pr.StartInfo.FileName +" "+ pr.StartInfo.Arguments);
//unfortunately my program breaks after the following line with System.ComponentMode.Win32Exception
pr.Start();
//never reaches the next lines
var proutput = pr.StandardOutput.ReadToEnd();
var prerror=pr.StandardError.ReadToEnd();
UnityEngine.Debug.Log("eror was: "+prerror);
UnityEngine.Debug.Log("output is: "+proutput);
return pr;
我还尝试做以下事情:
public static Process shell()
{
var pr = new Process();
pr.StartInfo = new ProcessStartInfo(@"c:\windows\system32\netstat.exe", "-n"){
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardInput = true,
RedirectStandardError = true
};
UnityEngine.Debug.Log("attempting start with: "+pr.StartInfo.FileName +" "+ pr.StartInfo.Arguments);
//No Exception here and
pr.Start();
//output works just fine
var proutput = pr.StandardOutput.ReadToEnd();
UnityEngine.Debug.Log("output is: "+proutput);
pr.WaitForExit();
return pr;
最让我困惑的是,如果我手动输入控制台命令,我会得到正确的输出......
我将非常感谢任何合理的解释或解决方案。