C# command not writing a line -
well hello, how make console write line? managed make run cmd.exe when u process it, doesnt write line.
private void button1_click(object sender, eventargs e) { if (textbox1.text == "alpha") { progressbar1.value = 100; if (progressbar1.value == 100) { messagebox.show("welcome master!"); system.diagnostics.process.start(@"c:\windows\system32\cmd.exe"); console.writeline("hello!!!"); } }
if want interact console process, need :-
var p = new process { startinfo = { filename = "cmd.exe", useshellexecute = false, redirectstandardinput = true, redirectstandardoutput = true } }; p.start(); var w = p.standardinput; w.writeline("dir"); w.writeline("exit"); var thedirectorylisting = p.standardoutput.readtoend(); p.waitforexit(); w.close(); p.close();
Comments
Post a Comment