一台装有xp,iis,vs2008的机子,在vs2008中,用
         p.StartInfo.FileName = @"cmd.exe";
         p.Start();
    能打开cmd.exe程序,但在iis中,通过网址访问,例如: http://localhost/afg/ 访问时,不能打开cmd.exe程序,估计是权限的问题,这权限到底该怎样设置?    还有,如果想向这个打开的cmd.exe程序中写入命令,例如: dir d: , 网上介绍用
      p.StandardInput.WriteLine("dir d:");
    但试过,是不行的. 
      p.StartInfo.Arguments = @"/c dir d:"; 也是不行的.
      到底怎样才能向打开的cmd.exe程序传送命令?

解决方案 »

  1.   

    没做过,看一看这个
    http://mxdev.blogspot.com/2008/09/asp-net-run-application-exe-from-aspnet.html
      

  2.   

    http://topic.csdn.net/t/20040412/10/2953500.html
      

  3.   

    参考protected void Button1_Click(object sender, EventArgs e)
    {
      string strFilePath="F:\\read.bat";
      
      ProcessStartInfo psi=new ProcessStartInfo("cmd.exe");
      psi.UseShellExecute=false;
      psi.RedirectStandardOutput=true;
      psi.RedirectStandardInput=true;
      psi.RedirectStandardError=true;
      psi.WorkingDirectory="F:\\";  Process proc=Process.Start(psi);  StreamReader sr=File.OpenText(strFilePath);
      StreamReader sOut=proc.StandardOutput;
      StreamWriter sw=proc.StandardInput;  while(sr.Peek()!=-1)
      {
        sw.WriteLine(sr.ReadLine());
      }
    }bat中的内容就是要在cmd中执行的命令,例如dir
      

  4.   

    调用cmd命令时,需要用系统管理员的身份呦
      

  5.   

    现在的问题是: 能调用到cmd命令了,在任务管理器中能看到了.
    但问题是cmd的窗口不显示出来.有什么办法让他显示出来?