如何使用C#中的参数编写启动应用程序的应用程序?

时间:2009-11-20 13:18:57

标签: c# process

如果我想编写一个使用参数启动Firefox的应用程序?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Launcher
{
  public static class Program
  {
    public static void Main(string[] args)
    {
      Process.Start("C:/Program Files/Mozilla Firefox/firefox.exe");//this is ok
      Process.Start("C:/Program Files/Mozilla Firefox/firefox.exe -P MyProfile -no-remote");// this doesn't work
    }
  }
}

2 个答案:

答案 0 :(得分:6)

您需要指定process.StartInfo.Arguments

请参阅此问题:Calling an application from ASP.NET MVC

答案 1 :(得分:0)

您需要使用process.StartInfo.Arguments,如下所示:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Launcher
{
  public static class Program
  {
    public static void Main(string[] args)
    {

        Process firefox = new Process();

        firefox.StartInfo.FileName = @"C:\Program Files\Mozilla Firefox\firefox.exe";
        firefox.StartInfo.Arguments = "-P MyProfile -no-remote";

        firefox.Start();

    }
  }
}