I am running an exe through commandline and getting following output.
i am running this through System.daignostics.process.
Following is the code i have tired...
string command = @"C:\Users\sysadmin\Desktop\Setup\PatchInstaller.exe";
string result = string.Empty;
System.Diagnostics.ProcessStartInfo procStartInfo = new ProcessStartInfo();
procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c " + command + " --mode=silent);
System.Diagnostics.Process proc = new Process();
procStartInfo.ErrorDialog = false;
procStartInfo.UseShellExecute = false;
procStartInfo.RedirectStandardOutput = true;
procStartInfo.RedirectStandardError = true;
procStartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
// Do not create the black window.
procStartInfo.CreateNoWindow = true;
if (!string.IsNullOrEmpty(domain) && !string.IsNullOrEmpty(user) && !string.IsNullOrEmpty(pwd))
{
procStartInfo.Domain = domain;
procStartInfo.UserName = user;
System.Security.SecureString ss = new System.Security.SecureString();
foreach (char c in pwd) { ss.AppendChar(c); }
procStartInfo.Password = ss;
}
proc = System.Diagnostics.Process.Start(procStartInfo);
proc.ErrorDataReceived += delegate(object sender, System.Diagnostics.DataReceivedEventArgs errorLine)
{
if (errorLine.Data != null) result += "error:" + errorLine.Data +;
};
proc.OutputDataReceived += delegate(object sender, System.Diagnostics.DataReceivedEventArgs outputLine)
{
if (outputLine.Data != null) result += outputLine.Data +;
};
proc.BeginErrorReadLine();
proc.BeginOutputReadLine();
proc.WaitForExit();
Here my exe is running and it will execute the below line first,
C:\Users\sysadmin\Desktop\New_folder\Setup\PatchInstaller.exe --mode=silent
Now PatchInstaller.exe is internally executing other process, I am expecting the output from this internal process,
(Example A:
C:\Users\sysadmin\Desktop\New_folder\Setup\PatchInstaller.exe --mode=silent
C:\Windows\system32>Begin SetupUI mode: SilentError : Conflicting Processes running.Exit Code: 19) (Note: PatchInstaller.exe is thirdparty exe. When we are excuting from command-line we are getting (Example A) output. )