I have the following code which is working. My callback method is called with the program's output as it is generated.
var proc = new System.Diagnostics.Process();
//proc.StartInfo.Domain = DOMAIN;
//proc.StartInfo.UserName = USERNAME;
//proc.StartInfo.Password = BuildPasswordString();
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.FileName = EXEC_PATH;
proc.StartInfo.Arguments = EXEC_ARGS;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
proc.OutputDataReceived += proc_OutputDataReceived;
proc.BeginOutputReadLine();
proc.WaitForExit();
However, as soon as I uncomment those three lines regarding user credentials, everything stops working. The code executes without an error, but the process doesn't run and no output is received in my callback method.
How can I execute a separate process, collect its output asynchronously as it is generated, while using a specific user's credentials that don't match the executing process?
Update:
Building off of @Dos095-russ's answer, I tested out the same code with a console application instead of ASP.NET. It does work. So it is something within the ASP.NET environment that is causing the failure.