Posts

Showing posts from September, 2011

C# create a new process

Once in a while I find myself needing to spawn a process in C#.  The .net framework has some built in functionality to do this.  It's fairly trivial to just spawn a process and let it run.  .NET however allows us many options to customize the look and feel as well as the error output of the spawned process.  The example below simply fires up notepad with a default document.  You can customize this heavily as mentioned and not show windows, etc. You can read all about is on MSDN . // create and setup the process object chartProcess = new Process(); chartProcess.StartInfo.FileName = "notepad.exe"; // this is all optional setup // pass in any command line arguments if desired chartProcess.StartInfo.Arguments = "test.txt"; // chartProcess.StartInfo.UseShellExecute = false; // this determines if we show the actual command or form window chartProcess.StartInfo.CreateNoWindow = false; // this lets us handle an event when the process we start stops chartProcess