人家的程序有的能模拟CMD窗口,在程序里输入平常的一些命令,比如dir,比如ping,都能得到于CMD中同样的回馈信息,它们是怎么做的?.Net里面有没有这种类呢?
比如我想用IPC$连上别人的机子,用C#做个全自动的程序,我应该用什么类呢?

解决方案 »

  1.   

    private void button1_Click(object sender, EventArgs e)
    {
    try
    {
    Process p = new Process();
    p.StartInfo.FileName = "cmd.exe";
    p.StartInfo.UseShellExecute = false;
    p.StartInfo.RedirectStandardInput = true;
    p.StartInfo.RedirectStandardOutput = true;
    p.StartInfo.RedirectStandardError = true;
    p.StartInfo.CreateNoWindow = true;
    p.Start();
    p.StandardInput.WriteLine("ping 172.16.1.1");
    p.StandardInput.WriteLine("exit");
    string strRst = p.StandardOutput.ReadToEnd();
    p.WaitForExit();
    this.label1.Text = strRst;
    }
    catch (Exception err)
    {
    MessageBox.Show(err.Message); //显示错误信息。
    }
    }
      

  2.   

    http://www.codeproject.com/cs/miscctrl/shellcontrol.asp
      

  3.   

    http://www.thecodeproject.com/csharp/winconsole.asp
    http://www.codeproject.com/useritems/commandprompt.asp