使用c# 启动exe可执行文件,这个已经实现。代码如下:Process process = new Process();
            process.StartInfo.FileName = "nginx.exe";
            process.StartInfo.WorkingDirectory = "E:\path\";
            process.StartInfo.CreateNoWindow = true;
            process.Start();
            process.WaitForExit();
目前这个已经可以正常的启动E:\path\nginx.exe文件但是还需要启动php-cgi.exe响应的文件。问题是启动php-cgi.exe时候需要指定其端口号
编写的bat启动脚本是:..\php\php-cgi -b 0.0.0.0:9003
也就是说需要带上端口号之类的,才能正常的启动php-cgi请问这个程序应该如何来写呢? 在线等。。谢谢各位大牛 

解决方案 »

  1.   

    还用process启动php-cgi.exe,设置 StartInfo.Arguments为 0.0.0.0:9003
      

  2.   


    Process process = new Process();
    process.StartInfo.FileName = "php-cgi.exe";             process.StartInfo.WorkingDirectory = "E:\path\";             process.StartInfo.CreateNoWindow = true;
    process.StartInfo.Arguments = "0.0.0.0:9003";
    process.Start();
    process.WaitForExit(); 
    ??这样吗?
    好像不行啊。
      

  3.   

      
          /// <summary>
                /// The main entry point for the application.
                /// </summary>
                [STAThread]
                static void Main(string[] args)
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    string version = null;
                    if (args != null && args.Length > 0)
                    {
                        version = args[0];
                    }
                    Application.Run(new AppUpdater(version));
      ProcessStartInfo startInfo = new ProcessStartInfo();
                            startInfo.FileName = Application.StartupPath + @"\AddUpdater.exe";
                            startInfo.WindowStyle = ProcessWindowStyle.Normal;
                            startInfo.Arguments = newVersion;//带入的参数
                            Process.Start(startInfo);