There is such a script
@echo off xcopy /R /Y "D:\test.dll" "C:\Users\testuser\Desktop"
If you run it, it correctly processes and copies the file. If you run it from this code, the file for some reason is not copied! But the most interesting fact is that if I disable RedirectStandardOutput
then the file is copied. What is the problem?
var processInfo = new ProcessStartInfo("cmd.exe", "/c " + @"D:\test.bat"); processInfo.WorkingDirectory = windir; processInfo.CreateNoWindow = true; processInfo.UseShellExecute = false; processInfo.RedirectStandardOutput = true; processInfo.StandardOutputEncoding = Encoding.GetEncoding(866); var process = Process.Start(processInfo); process.OutputDataReceived += (object sender, DataReceivedEventArgs e) => { if (!string.IsNullOrWhiteSpace(e.Data)) { LogTextEvent(rtbLog, Color.Black, e.Data); } }; process.BeginOutputReadLine(); process.WaitForExit(); process.Close();
\r\n
(no). - nick_n_a