I'm looking to use Process.Start() to launch an executable, but I want to continue program execution regardless of whether the executable succeeds or fails, or whether Process.Start() itself throws an exception.
I have this:
myProcess.StartInfo.UseShellExecute = false;
// You can start any process, HelloWorld is a do-nothing example.
myProcess.StartInfo.FileName = "C:\\HelloWorld.exe";
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();
I know you can add this into try catch
try
{
myProcess.StartInfo.UseShellExecute = false;
// You can start any process, HelloWorld is a do-nothing example.
myProcess.StartInfo.FileName = "C:\\HelloWorld.exe";
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
Try catch version will not fail if file not found? How to go with other exception like InvalidOperationException Win32Exception ObjectDisposedException
The goal is just to continue with the code if this fail...
Thanks a lot!