End Google Ads 201810 - BS.net 01 --> Hello,

I have created a Process that runs a command from cmd and handles it's output using event Handler.

I want to input user name when cmd asks for "Enter Username :". This comes immediately after 1st line. Then comes Enter Password where I want to pass password. Then their is no input and can use my event handler till I am done.

I tried the following, but didn't work :
processInfo = new ProcessStartInfo("cmd.exe", "/C " + command);
sb = new StringBuilder();
processInfo.UseShellExecute = false;
processInfo.RedirectStandardOutput = true;
processInfo.CreateNoWindow = true;
public int ConnectToServer()
{
processInfo.RedirectStandardInput = true;
process = Process.Start(processInfo);

process.StandardInput.WriteLine("username");
process.StandardInput.Flush();
process.StandardInput.WriteLine("myPswd$");
process.StandardInput.Flush();
process.StandardInput.Close();

process.BeginOutputReadLine();
process.OutputDataReceived += new DataReceivedEventHandler(Process_OutputDataReceived);
}

private void Process_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
string d = e.Data;

if (!string.IsNullOrEmpty(d))
{
if (d.indexOf("Completed")) {
connected = true;
}
}
}
It shows error authentication failed. I guess I didn't input username & passowrd on time, so this must have happened. How to know when the app is asking to write and to write proepr details ? I didn't find such way of inputting in any articles searched on internet.

Any help is highly appreciated.
Thanks & Regards,