C#从一个进程开启另一个进程,并传参数到进程中

1.开启进程

using System.Diagnostics;

ProcessStartInfo process = new ProcessStartInfo();
process.FileName = "要开启的进程路径"; 
string arg1 =  "进程参数1";
string arg2 =  "进程参数2";
process.Arguments = string.Format("{0} {1}", arg1, arg2) ;  //多个参数用空格隔开
process.WindowStyle = ProcessWindowStyle.Normal;
Process.Start(process);

2.修改要开启进程的Main函数

/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)   //这里的 args 就为 {arg1,arg2} 了
{
   Application.EnableVisualStyles();
   Application.SetCompatibleTextRenderingDefault(false);
   Application.Run(new Form1(args));
}
原文地址:https://www.cnblogs.com/bridgew/p/12709084.html