在同一进程 (window) 中执行多个 CMD 命令而不显示单独的 windows
Execute multiple CMD commands in same process (window) without showing separate windows
我正在使用代码解析器 CTAG,它一次解析一个文件并在文本文件中报告结果。我有一个文件列表,我使用以下代码解析和处理它们的输出。
string folder = "C:\Temp\";
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = folder + "command.bat";
foreach (string file in files)
{
string command = @"ctags -R --c++-kinds=+p --fields=+iaS --extra=+q " + file;
File.WriteAllText(folder + "command.bat", "cd " + folder + Environment.NewLine + command);
p.Start();
p.WaitForExit();
string[] str = File.ReadAllLines(folder + "tags");
ProcessParsedCode(str);
}
上面的代码不断打开和关闭一个新的 window 来解析每个看起来很难看的文件,因为我有超过 100 个文件。我想在一个命令中完成此操作 window.
您是 运行 'files' 中每个 'file' 的进程。因此,如果您有 100 个文件,将产生 100 个命令 windows。
如果您对这些命令 windows 中包含的输出不感兴趣(并且当您将结果输出到文本文件时,我认为不会),您可以将它们隐藏起来全部 p.StartInfo.CreateNoWindow = true;
.
我正在使用代码解析器 CTAG,它一次解析一个文件并在文本文件中报告结果。我有一个文件列表,我使用以下代码解析和处理它们的输出。
string folder = "C:\Temp\";
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = folder + "command.bat";
foreach (string file in files)
{
string command = @"ctags -R --c++-kinds=+p --fields=+iaS --extra=+q " + file;
File.WriteAllText(folder + "command.bat", "cd " + folder + Environment.NewLine + command);
p.Start();
p.WaitForExit();
string[] str = File.ReadAllLines(folder + "tags");
ProcessParsedCode(str);
}
上面的代码不断打开和关闭一个新的 window 来解析每个看起来很难看的文件,因为我有超过 100 个文件。我想在一个命令中完成此操作 window.
您是 运行 'files' 中每个 'file' 的进程。因此,如果您有 100 个文件,将产生 100 个命令 windows。
如果您对这些命令 windows 中包含的输出不感兴趣(并且当您将结果输出到文本文件时,我认为不会),您可以将它们隐藏起来全部 p.StartInfo.CreateNoWindow = true;
.