views:

265

answers:

3

Just like the subject states. I want to be able to run iisreset, batch files, etc. from the a console application. Can I/How do I do it?

Thanks,

Kyle

+5  A: 

That's quite possible, for example:

 System.Diagnostics.Process.Start(@"C:\listfiles.bat");
Otávio Décio
+3  A: 

Hi, Check this example from C# Station

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();
        }
    }
}
Ric Tokyo
+2  A: 

You can also do this:

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



  Console.ReadLine();
Greco