C# 我可以使用命令行,还是从托管代码运行批处理文件?(.NET)

C# 我可以使用命令行,还是从托管代码运行批处理文件?(.NET),c#,.net,command-line,C#,.net,Command Line,就像主体陈述的那样。我希望能够从控制台应用程序运行iisreset、批处理文件等。我能/怎么做呢?这很有可能,例如: System.Diagnostics.Process.Start(@"C:\listfiles.bat"); 请从中检查此示例 使用系统; 使用系统诊断; 命名空间csharp_station.howto { /// ///演示如何从C启动另一个程序# /// 类ProcessStart { 静态void Main(字符串[]参数) { 进程记事本=新进程(); note

就像主体陈述的那样。我希望能够从控制台应用程序运行iisreset、批处理文件等。我能/怎么做呢?

这很有可能,例如:

 System.Diagnostics.Process.Start(@"C:\listfiles.bat");
请从中检查此示例

使用系统;
使用系统诊断;
命名空间csharp_station.howto
{
/// 
///演示如何从C启动另一个程序#
/// 
类ProcessStart
{
静态void Main(字符串[]参数)
{
进程记事本=新进程();
notePad.StartInfo.FileName=“notePad.exe”;
notePad.StartInfo.Arguments=“ProcessStart.cs”;
notePad.Start();
}
}
}

您也可以这样做:

  System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo();
  info.UseShellExecute = true;
  info.FileName = "iisreset";
  System.Diagnostics.Process.Start(info);



  Console.ReadLine();
  System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo();
  info.UseShellExecute = true;
  info.FileName = "iisreset";
  System.Diagnostics.Process.Start(info);



  Console.ReadLine();