0

I want to use ProcessStartInfo to startup programs from my C# application. I am using ProcessStartInfo insted of normal Process because I want to startup programs minimized so I will be using ProcessWindowStyle.Minimized and maybe I will also pass some arguments. I also want to monitor those started applications after so I want to use for example Process.HasExited property (and also PeakWorkingSet64) but I can't as I got an error 'System.Diagnostics.ProcessStartInfo' does not contain a definition for 'HasExited'. Is there any way to start applications with ProcessStartInfo and also using properties that are available with standard Process class?

Cassie Kasandr
  • 341
  • 2
  • 6
  • 15

2 Answers2

2

ProcessStartInfo is just a structure that describes how to start a process. Once you define it, you pass it to Process.Start() and get back instance of Process. On that instance you can call .HasExited.

LB2
  • 4,802
  • 19
  • 35
2

ProcessStartInfo is a class that defines settings that you want to pass into an overload of Process.Start.

So, you would typically do something like this:

var psi = new ProcessStartInfo { ... };
var process = Process.Start("C:\myProgram.exe", psi);
process.Exited += myProcessExitHandler;
Brian Driscoll
  • 19,373
  • 3
  • 46
  • 65