Given a particular System.Diagnostics.Process that has been assigned values to its properties .FileName and .Arguments, what is the best way to determine if it:
- has ever been issued a
.Start()command or - is currently associated with a process at all?
If .Start() was never issued, then calling .CloseMainWindow() causes an InvalidOperationException, which I’d like to avoid.
Have you tried checking
Process.Idand one of the Exit properties ?Ref.
In response to poster’s comments: perhaps you will have to wrap in a try/catch and an exception being thrown indicates not started? It’s not pretty!