我想在网站里执行cmd的操作.
举个简单的例子就是
一个输入框.输入ip之后点击一按钮.在以显示区域显示ping值之类的信息
请问要做到这样需要用到哪方面的东西
上面说的只是个例子.我就是想执行cmd操作 图形界面化而已.
谢谢

解决方案 »

  1.   

        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Write(ExeCommand("ping 192.168.155.133"));
        }    public string ExeCommand(string commandText)
        {
            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;
            string strOutput = null;
            try
            {
                p.Start();
                p.StandardInput.WriteLine(commandText);
                p.StandardInput.WriteLine("exit");
                strOutput = p.StandardOutput.ReadToEnd();
                p.WaitForExit();
                p.Close();
            }
            catch (Exception e)
            {
                strOutput = e.Message;
            }
            return strOutput;
        }
      

  2.   

    在Asp.Net中执行cmd可以使用Process 或者是WMI,但是如果想返回执行的相关信息就没有办法了。