I want to launch a command line program from C# code, then when it finishes relaunch the process again.
The command line program downloads some files and kills the C# process, and I need to relaunch my C# program when the command line process is finished. I've tried the following:
Process p = new Process();
p.StartInfo.UseShellExecute = true;
p.StartInfo.WorkingDirectory = path-to-the-cmd-program;
p.StartInfo.FileName = cmd-program-name;
p.StartInfo.Arguments = "--arg1 blah --arg2 blah & path-to-csharp-program\\c-sharp-program.exe"
p.Start();
But for some reason, when the command line process finishes (it finishes successfully), the rest of the arguments (which should call the C# program again) get ignored.
If I try to do the same from cmd, it works as expected: process 1 finishes, then C# program is launched.
I also tried trying to set the p.Exited event handler, but of course, C# process is killed so the event handler does not fire.
Thank you very much.