注意:
info.CreateNoWindow=true;info.RedirectStandardOutput=false;

解决方案 »

  1.   

    ProcessStartInfo  Info  =  new  ProcessStartInfo();
    Info.FileName  =  "regedit.exe";
    Info.WorkingDirectory  =  "C:\\";
    Process  Proc = new Process();
    try
    {
    Proc = Process.Start(Info);
    }
    catch(System.ComponentModel.Win32Exception  ce)
    {
             //this.display1.AppendText(ce.ToString() + "\r");
    MessageBox.Show(ce.ErrorCode.ToString());
    }
    finally
    {
             Proc.Dispose();
    }因为你指定的Exe文件未找到导致的异常
      

  2.   

    Process pro = new Process();
    pro.StartInfo.UseShellExecute = false;
    pro.StartInfo.RedirectStandardError = true;
    pro.StartInfo.RedirectStandardInput = true;
    pro.StartInfo.RedirectStandardOutput = true;
    pro.StartInfo.FileName = FileName;
    pro.StartInfo.Arguments = Arguments;
    pro.StartInfo.CreateNoWindow = true;
    pro.Start();在 FileName=@“C:\cpro.exe”就可以了
    如果要添加参数
    在 Arguments = "-s result.dat"//你要处理的文件名
      

  3.   

    我再写一遍报错的信息:
    未处理的“System.InvalidOperationException”类型的异常出现在 system.dll 中。
    其他信息: 进程已退出,因此无法获得所请求的信息。我又试了试,把程序后面的要求显示外部程序的开始和结束时间的代码
    display1.AppendText("开始执行时间:" + Proc.StartTime.ToString()+ "\r");
    display1.AppendText("结束执行时间:" + Proc.ExitTime.ToString() + "\r");
    屏蔽掉就不报错了。为什么啊,难道无法取tc编的可执行程序的这个信息?请高手在支招!
      

  4.   

    另外还想请教高手,如果我做的安装程序把这个外部程序包含进去,我的Info.WorkingDirectory或者FileName=@“C:\cpro.exe”应该怎么写,才能获取用户定义的安装路径动态的改变呢?