我有一个 child.exe,它接受命令行参数。我需要从另一个 parent.exe 应用程序启动该 child.exe,并且需要将不同的命令行参数传递给该 child.exe。我尝试使用以下代码。
Process process = new Process();
process.StartInfo.FileName = @"R:\bin\child.exe";
process.StartInfo.Arguments = "CONSUMER";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.CreateNoWindow = true;
process.Start();
process = new Process();
process.StartInfo.FileName = @"R:\bin\child.exe";
process.StartInfo.Arguments = "SUPERVISOR";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.CreateNoWindow = true;
process.Start();
但是这里的问题是每次我调用 process.Start() 时,都会创建一个单独的 exe。我只需要一个运行的 child.exe 实例,它可以接受不同的命令行参数。任何帮助表示赞赏。