I am working on a project that needs the cmd will run the application.
with an automatic filling of the textbox of application.
Currently, I have seen this code, but this does not work.
It throws this exception - StandardIn has not been redirected
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = @"C:\Windows\System32\cmd.exe";
process.StartInfo = startInfo;
process.StandardInput.WriteLine(@"C:\Program Files\WinMerge\WinMergeU.exe" + txtJOB.Text + txtKJOB.Text + "- minimize - noninteractive - noprefs - cfg Settings / DirViewExpandSubdirs = 1 - cfg ReportFiles / ReportType = 2 - cfg ReportFiles / IncludeFileCmpReport = 1 - r - u -or" + txtResultPath.Text);
process.Start();
If i use cmd and run this line
"C:\Program Files\WinMerge\WinMergeU.exe" + txtJOB.Text + txtKJOB.Text + "- minimize - noninteractive - noprefs - cfg Settings / DirViewExpandSubdirs = 1 - cfg ReportFiles / ReportType = 2 - cfg ReportFiles / IncludeFileCmpReport = 1 - r - u -or" + txtResultPath.Text
this does work. but how will i Implement this command line in c#?
can someone help me with this?
Thanks in Advance.
Your exception is thrown because you writing a command to standart input of process (
process.StandardInput.WriteLine()
) before you actually start process (process.Start()
).If you just need to start a
WinMergeU
- you don't need to callcmd.exe
at all, this can be done like this: