开发者

How to write an app-launching application with arguments in C#?

How to if I want to write an application that launches Firefox with 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 Ma开发者_JS百科in(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
    }
  }
}


You will need to specify the process.StartInfo.Arguments

See this question: Calling an application from ASP.NET MVC


You will need to use the process.StartInfo.Arguments, as shown here:

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();

    }
  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜