【发布时间】:2016-01-04 03:39:44
【问题描述】:
我的代码启动了一个包含 3 个由空格分隔的参数的进程。
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = exeLauncher;
info.Arguments = path + " " + exeName + " " + restartNeeded;
Process process = new Process();
Process.Start(info);
我正在解析我开始的进程的参数并进行一些处理。
static void Main(string[] args)
{
Console.WriteLine(args[0]);
Console.WriteLine(args[1]);
Console.WriteLine(args[2]);
//some more processing here
Console.ReadLine();
}
处理后,我希望控制台窗口自行关闭。我曾尝试使用像这样的/c 参数,但它只是将其解释为纯字符串。
info.Arguments = "/c" + path + " " + exeName + " " + restartNeeded;
我也尝试将参数括在"" 双引号中,但它不起作用。
info.Arguments = string.Format("/c \"{0} {1} {2}\"", path, exeName, restartNeeded);
【问题讨论】:
-
为什么不删除会关闭控制台的
Console.ReadLine();
标签: c# command-line process arguments