类似于 Process.Start("IEXPLORE.EXE") immediately fires the Exited event after launch.. why?
-nomerge选项似乎不适用于firefox。
更新:
以下是控制台应用程序中C#代码的预览
static bool exitCalled = false;
static string baseUrl = <some url to display in the browser>;
var process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "Firefox.exe"
Arguments = " -url " + baseUrl + " -no-remote -P MyProfile "
}
}
process.EnableRaisingEvents = true;
process.Exited += new EventHandler(delegate(Object o, EventArgs e)
{
// process has exited
Console.WriteLine("Exited event called");
Console.ReadLine();
exitCalled = true;
}
process.Start();
while (!exitCalled)
{
Thread.Sleep(100);
}
运行这段代码会在调用浏览器之前显示“已调用的已触发事件”消息。
答案 0 :(得分:1)
因为-nomerge
是IE特定的程序参数,对于firefox,您需要使用-no-remote
。您还需要将-P
程序参数传递给它,因为不建议使用默认配置文件启动另一个firefox进程。有关启动新FireFox实例的信息,请参阅以下链接:
http://kb.mozillazine.org/Opening_a_new_instance_of_Firefox_with_another_profile