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?
That's quite possible, for example:
System.Diagnostics.Process.Start(@"C:\listfiles.bat");
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();
}
}
}
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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With