Click here to Skip to main content
15,886,067 members
Home / Discussions / C#
   

C#

 
AnswerRe: change the shape of the tab header in tab control PinPopular
Luc Pattyn4-Feb-11 2:06
sitebuilderLuc Pattyn4-Feb-11 2:06 
GeneralRe: change the shape of the tab header in tab control Pin
NarVish6-Feb-11 17:41
NarVish6-Feb-11 17:41 
GeneralRe: change the shape of the tab header in tab control Pin
Luc Pattyn6-Feb-11 21:15
sitebuilderLuc Pattyn6-Feb-11 21:15 
Questionc# Client Server Application Pin
LAPEC4-Feb-11 1:35
LAPEC4-Feb-11 1:35 
AnswerRe: c# Client Server Application Pin
RobCroll4-Feb-11 1:49
RobCroll4-Feb-11 1:49 
AnswerRe: c# Client Server Application Pin
phil.o4-Feb-11 2:21
professionalphil.o4-Feb-11 2:21 
AnswerRe: c# Client Server Application Pin
_Erik_4-Feb-11 5:39
_Erik_4-Feb-11 5:39 
QuestionInput details in cmd via Process Pin
All Time Programming4-Feb-11 0:10
All Time Programming4-Feb-11 0:10 
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,


AnswerRe: Input details in cmd via Process Pin
Xmen Real 4-Feb-11 1:23
professional Xmen Real 4-Feb-11 1:23 
GeneralRe: Input details in cmd via Process Pin
All Time Programming4-Feb-11 1:42
All Time Programming4-Feb-11 1:42 
AnswerRe: Input details in cmd via Process Pin
PIEBALDconsult4-Feb-11 1:48
mvePIEBALDconsult4-Feb-11 1:48 
GeneralRe: Input details in cmd via Process Pin
All Time Programming4-Feb-11 2:44
All Time Programming4-Feb-11 2:44 
AnswerRe: Input details in cmd via Process Pin
_Erik_4-Feb-11 6:09
_Erik_4-Feb-11 6:09 
QuestionPreserve stack trace after Exception rethrow? Pin
Chesnokov Yuriy3-Feb-11 22:57
professionalChesnokov Yuriy3-Feb-11 22:57 
AnswerRe: Preserve stack trace after Exception rethrow? Pin
Wayne Gaylard3-Feb-11 23:03
professionalWayne Gaylard3-Feb-11 23:03 
QuestionRe: Preserve stack trace after Exception rethrow? Pin
Chesnokov Yuriy4-Feb-11 0:38
professionalChesnokov Yuriy4-Feb-11 0:38 
AnswerRe: Preserve stack trace after Exception rethrow? Pin
Luc Pattyn4-Feb-11 0:48
sitebuilderLuc Pattyn4-Feb-11 0:48 
QuestionTeechart - change color of bar in bar chart based on values Pin
PleaseHelpCP3-Feb-11 22:49
PleaseHelpCP3-Feb-11 22:49 
QuestionEfficient way to handle search page Pin
Umair Feroze3-Feb-11 22:34
Umair Feroze3-Feb-11 22:34 
QuestionWindows program responding to win + d Pin
ayandelhi3-Feb-11 21:57
ayandelhi3-Feb-11 21:57 
AnswerRe: Windows program responding to win + d Pin
Luc Pattyn3-Feb-11 22:23
sitebuilderLuc Pattyn3-Feb-11 22:23 
GeneralRe: Windows program responding to win + d Pin
ayandelhi3-Feb-11 23:31
ayandelhi3-Feb-11 23:31 
AnswerRe: Windows program responding to win + d Pin
Luc Pattyn3-Feb-11 23:41
sitebuilderLuc Pattyn3-Feb-11 23:41 
GeneralRe: Windows program responding to win + d Pin
ayandelhi3-Feb-11 23:51
ayandelhi3-Feb-11 23:51 
QuestionC# method to restart the application Pin
ayandelhi3-Feb-11 18:56
ayandelhi3-Feb-11 18:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.