就像主题一样。我希望能够从控制台应用程序运行iisreset,批处理文件等。我可以/我该怎么做?
答案 0 :(得分:6)
这很可能,例如:
System.Diagnostics.Process.Start(@"C:\listfiles.bat");
答案 1 :(得分:3)
using System;
using System.Diagnostics;
namespace csharp_station.howto
{
/// <summary>
/// Demonstrates how to start another program from C#
/// </summary>
class ProcessStart
{
static void Main(string[] args)
{
Process notePad = new Process();
notePad.StartInfo.FileName = "notepad.exe";
notePad.StartInfo.Arguments = "ProcessStart.cs";
notePad.Start();
}
}
}
答案 2 :(得分:2)
你也可以这样做:
System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo();
info.UseShellExecute = true;
info.FileName = "iisreset";
System.Diagnostics.Process.Start(info);
Console.ReadLine();