当前位置:编程学习 > C#/ASP.NET >>

c# 执行 dos在服务器上执行不成功。 VS上可以

  string strOutput = command+c;
                Process p = null;
                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(strOutput);
                p.StandardInput.WriteLine("exit");
                while (p.StandardOutput.EndOfStream)
                {
                    strOutput = p.StandardOutput.ReadLine();
                    Console.WriteLine(strOutput);
                }
                p.WaitForExit();
                p.Close(); --------------------编程问答--------------------
引用 楼主 jhl52771 的回复:
string strOutput = command+c;
                Process p = null;
                p = new Process();
                p.StartInfo.FileName = "cmd.exe";
                p.StartInfo.UseS……

权限设置问题:
vs 本地运行相当用你登录的用户权限
在服务器要这么做,挺多设置的,而且也不是很安全。

如果一定要这么做, 这里有一个链接,你参考一下
http://forums.asp.net/t/1757464.aspx/1

--------------------编程问答-------------------- 没有权限吧~
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,