I write this code bellow to run an .exe
file in my program and its work just fine except that the process never end so the program don't proceed after the proc.WaitForExit();
line. I tried to read the StandartInput
and nothing change. What can be the reason?
My code:
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = "cmd.exe";
proc.StartInfo.WorkingDirectory = @"D:\";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.RedirectStandardInput = true;
proc.Start();
proc.StandardInput.WriteLine("cd " + directory);
proc.StandardInput.WriteLine(exeFile + arguments);
proc.WaitForExit();`
Note: if i run the exe file through cmd in windows its work great.
Thank you.