C#中如何使用Process.Start()使一个无gui的exe应用程序在后台启动?
我使用
        ProcessStartInfo startInfo = new ProcessStartInfo("D:ack.exe");
        startInfo.WindowStyle = ProcessWindowStyle.Hidden;
        Process.Start(startInfo);
不起作用,ack.exe程序 还是在前台

解决方案 »

  1.   

    startInfo.StartInfo.CreateNoWindow = true;
    这样看看能行不
      

  2.   

    StartInfo.CreateNoWindow = true;
    http://social.microsoft.com/Forums/zh-CN/vbasiczhchs/thread/7755f23d-55ae-485a-951c-668d1d4fbf16/
      

  3.   

    谢谢
    我的代码是
                Process proRestart= new Process();
                //设置隐藏窗口
                proRestart.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                proRestart.StartInfo.FileName = "D:/ack.exe";
                proRestart.StartInfo.CreateNoWindow = true;
                proRestart.StartInfo.UseShellExecute = true;
                proRestart.Start();
    那个黑色窗口还有。。
    可能是我的问题 没有说清楚,我用process调用ack.exe这个程序,想把ack.exe这个程序隐藏在后台执行,不让他显示一个窗口
      

  4.   


    private void btnExecute_Click(object sender, EventArgs e)
            {
                tbResult.Text = "";
                ProcessStartInfo start = new ProcessStartInfo("Ping.exe");//设置运行的命令行文件问ping.exe文件,这个文件系统会自己找到
                //如果是其它exe文件,则有可能需要指定详细路径,如运行winRar.exe
                start.Arguments = txtCommand.Text;//设置命令参数
                start.CreateNoWindow = true;//不显示dos命令行窗口
                start.RedirectStandardOutput = true;//
                start.RedirectStandardInput = true;//
                start.UseShellExecute = false;//是否指定操作系统外壳进程启动程序
                Process p=Process.Start(start);
                StreamReader reader = p.StandardOutput;//截取输出流
                string line = reader.ReadLine();//每次读取一行
                while (!reader.EndOfStream)
                {
                    tbResult.AppendText(line+" ");
                    line = reader.ReadLine();
                }
                p.WaitForExit();//等待程序执行完退出进程
                p.Close();//关闭进程
                reader.Close();//关闭流
            }
      

  5.   


    我用process调用ack.exe这个程序,是一个窗口程序
    想把ack.exe这个程序隐藏在后台执行,不让他显示一个窗口你说的这个例子 是ping输出到流中,而我这里ack.exe是一个程序
      

  6.   

    呵呵.用CreateProcess API 把你要调用的shell程序(就是你的ACK.EXE) 设到另一个桌面上就不会出窗口了.(当然这个桌面得先存在.你可以CreateDeskTop来创建这个桌面)如果还不明白的话.MM我.发个demo给你看看.
      

  7.   


    的确不明白
    发一个dwmo吧
     
    谢谢
      

  8.   


    窗口确实没有了 
    在 任务管理器 里 可以看到ACK.EXE 这个进程名字
    兄弟 有没有办法修改 进程里面的 这个ACK.EXE映像名字?