Command editor is a program calling one process and excute any parameters may be passed to it, so mainly my work and my example here is cmd.exe .
How it is work?
Many times you need to open command prompet to do some operation on it i.e dir, del, ping, ...etc.
Here you can just write command in the first textbox i.e ( cmd.exe ), and write the operaation you need to do and click start or just press enter from key borad the command you typed will be excuted and the result will be printed on the text area in the right side beside the status in the
- You can browse any file you want exe file specially those which console application like any consol application takes parameters.
- You can also type the command in the text area and press enter it will be excuted.
- Also you can save the result from in text format by click save log button.
- You can also type the command in the text area and press enter it will be excuted.
- Also you can save the result from in text format by click save log button.
Sample Code:
private void excute(string command, string argument)
{
p = new Process();
p.StartInfo.FileName =command;
p = new Process();
p.StartInfo.FileName =command;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
myStreamReader = p.StandardOutput;
myStreamReader2 = p.StandardError;
p.StandardInput.Write(paramater);
p.StandardInput.WriteLine();
p.StandardInput.Close();
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
myStreamReader = p.StandardOutput;
myStreamReader2 = p.StandardError;
p.StandardInput.Write(paramater);
p.StandardInput.WriteLine();
p.StandardInput.Close();
.
.
.
.
}
and for key press
if(e.KeyValue==13)//enter
{
s=txt_result.Text.Substring(i+1).ToString();
excute(txt_command.Text,s.Substring(0,s.Length));
s=null;
}
This all done.
Osama Gamal 2007
No comments:
Post a Comment