Unable to hide command prompt in C# windows form application visual studio 2010 -
this question has answer here:
- hide console window process.start c# 3 answers
i have made application in c# visual studio 2010. in application sending ping
command cmd
, receiving output of cmd
in richtextbox
. here code:-
void proc_outputdatareceived(object sender, datareceivedeventargs e) { if (e.data != null) { string newline = e.data.trim() + environment.newline; methodinvoker append = () => txtoutput.text += newline; txtoutput.begininvoke(append); } } private void btnping_click(object sender, eventargs e) { string command = "/c ping " + txtping.text; processstartinfo procstartinfo = new processstartinfo("cmd", command); process proc = new process(); proc.startinfo = procstartinfo; proc.start(); procstartinfo.redirectstandardoutput = true; procstartinfo.useshellexecute = false; proc.outputdatareceived += new datareceivedeventhandler(proc_outputdatareceived); proc.start(); proc.beginoutputreadline(); proc.waitforexit(); }
my code working great issue cmd
getting popup when click on start
button. , want hide cmd
want show output in richtextbox.
so, question is, how can hide cmd
in application. here screen shot of problem.
try adding these lines. worked me.
procstartinfo.createnowindow = true; procstartinfo.useshellexecute = false; procstartinfo.redirectstandardoutput = true;
Comments
Post a Comment