Click here to Skip to main content
   

C#

 
AnswerRe: Better code Pinmembersanthosh.3591@gmail.com14-Feb-13 9:19 
GeneralRe: Better code PinprofessionalAmir Mohammad Nasrollahi29-Jul-13 23:16 
AnswerRe: Better code PinmvpEddy Vluggen14-Feb-13 9:30 
GeneralRe: Better code Pinmembersource.compiler14-Feb-13 13:05 
GeneralRe: Better code PinmemberBull City Rambler14-Feb-13 13:58 
GeneralRe: Better code PinmvpEddy Vluggen14-Feb-13 22:01 
AnswerRe: Better code Pinmembercjb11015-Feb-13 1:59 
QuestionSend/Receive text to CMD from C# GUI Pinmemberadam.m.b.nelson14-Feb-13 4:13 
Hey there! I'm trying to write into a command prompt window (Not the debugger) from my C# GUI with no luck (I've looked at lots of examples), and I'm not sure where I am going wrong. The command prompt window will open, it will accept text if i type it in from my keyboard, but it won't accept it from my application.

I've tried with both the windows command prompt, and the custom one we are trying to write into. Long story short I am trying to access an AtmelAVR programmer from command line to automatically program devices in our assembly process. I can automatically program by command line when I enter the text myself, I just can't get out GUI to do it... I've attached my code below:

EDIT: Working in VS2010 on Windows 7

Any help is greatly appreciated!

<pre lang="c#"> 
Process PrgCommandPrmpt = new Process();
PrgCommandPrmpt.StartInfo.UseShellExecute = false;
PrgCommandPrmpt.StartInfo.FileName = "C:/Program Files (x86)/Atmel/Atmel Studio 6.0/extensions/Application/StudioCommandPrompt.exe";
            
PrgCommandPrmpt.StartInfo.RedirectStandardInput = true;
PrgCommandPrmpt.StartInfo.RedirectStandardOutput = true;
PrgCommandPrmpt.StartInfo.RedirectStandardError = true;
PrgCommandPrmpt.StartInfo.CreateNoWindow = true;
            
PrgCommandPrmpt.EnableRaisingEvents = false;
PrgCommandPrmpt.Start();
            
PrgCommandPrmpt.StandardInput.AutoFlush = true;
 
StreamWriter inputWriter = PrgCommandPrmpt.StandardInput;
StreamReader outputReader = PrgCommandPrmpt.StandardOutput;
StreamReader errorReader = PrgCommandPrmpt.StandardError;
            
            
myDelay5s();
tboxVerbose.AppendText("Doing stuff now!"); //This just outputs to a textbox to let me know something is happening.
string CommandText = "cd..";
            
inputWriter.WriteLine("WHY DONT YOU WORK");  //These are the two latest ways I tried to write to it, no luck.
PrgCommandPrmpt.StandardInput.Write(CommandText);//These are the two latest ways I tried to write to it, no luck.
inputWriter.Close();

AnswerRe: Send/Receive text to CMD from C# GUI PinmvpRichard MacCutchan14-Feb-13 4:45 
GeneralRe: Send/Receive text to CMD from C# GUI [modified] Pinmemberadam.m.b.nelson14-Feb-13 4:54 
GeneralRe: Send/Receive text to CMD from C# GUI PinmvpRichard MacCutchan14-Feb-13 5:57 
GeneralRe: Send/Receive text to CMD from C# GUI Pinmemberadam.m.b.nelson14-Feb-13 6:46 
GeneralRe: Send/Receive text to CMD from C# GUI Pinmemberadam.m.b.nelson14-Feb-13 6:56 
GeneralRe: Send/Receive text to CMD from C# GUI PinmvpRichard MacCutchan14-Feb-13 7:01 
GeneralRe: Send/Receive text to CMD from C# GUI Pinmemberadam.m.b.nelson14-Feb-13 7:57 
GeneralRe: Send/Receive text to CMD from C# GUI PinmvpRichard MacCutchan14-Feb-13 8:03 
GeneralRe: Send/Receive text to CMD from C# GUI Pinmemberadam.m.b.nelson14-Feb-13 8:45 
GeneralRe: Send/Receive text to CMD from C# GUI Pinmemberadam.m.b.nelson14-Feb-13 9:02 
GeneralRe: Send/Receive text to CMD from C# GUI PinmvpRichard MacCutchan14-Feb-13 7:29 
GeneralRe: Send/Receive text to CMD from C# GUI Pinmemberadam.m.b.nelson14-Feb-13 8:04 
GeneralRe: Send/Receive text to CMD from C# GUI PinmvpRichard MacCutchan14-Feb-13 8:21 
GeneralRe: Send/Receive text to CMD from C# GUI Pinmemberadam.m.b.nelson14-Feb-13 9:06 
GeneralRe: Send/Receive text to CMD from C# GUI PinmvpRichard MacCutchan14-Feb-13 10:41 
GeneralRe: Send/Receive text to CMD from C# GUI Pinmemberadam.m.b.nelson14-Feb-13 10:48 
GeneralRe: Send/Receive text to CMD from C# GUI PinmvpRichard MacCutchan14-Feb-13 11:08 

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

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


Advertise | Privacy | Mobile
Web03 | 2.8.150331.1 | Last Updated 2 Apr 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid