首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用System.Diagnostics运行cmd.exe

无法使用System.Diagnostics运行cmd.exe
EN

Stack Overflow用户
提问于 2015-01-31 05:39:43
回答 1查看 328关注 0票数 0

环境:Windows2.0、.Net 2003、64位

我正在尝试将网站从旧服务器移动到新服务器,移动代码后,以下代码不再起作用:

代码语言:javascript
复制
    System.Diagnostics.ProcessStartInfo psi = new
    System.Diagnostics.ProcessStartInfo("cmd.exe");
    psi.UseShellExecute = false;
    psi.RedirectStandardOutput = true;
    psi.RedirectStandardInput = true;
    psi.RedirectStandardError = true;
    // Start the process
    System.Diagnostics.Process proc = System.Diagnostics.Process.Start(psi);
    System.IO.StreamReader strm = proc.StandardError;
    System.IO.StreamReader sOut = proc.StandardOutput;

    // Attach the in for writing
    System.IO.StreamWriter sIn = proc.StandardInput;

    sIn.WriteLine(exec);

    strm.Close();
    sIn.WriteLine("EXIT");

    proc.Close();

    // Read the sOut to a string.
    string results = sOut.ReadToEnd().Trim();

    // Close the io Streams;
    sIn.Close();
    sOut.Close();

似乎系统不允许运行任何.exe。代码在以前的服务器上工作正常,所以我猜这是某些类型的系统配置问题。我在这里发现了类似的问题:Foo.cmd won't output lines in process (on website)

但是我不理解“创建一个具有执行批处理脚本权限的新用户并选择该用户作为IIS中的AppPool用户”这一部分,.I知道如何创建一个新用户,但不知道如何授予用户执行.exe或批处理文件的权限。

任何建议都会有所帮助。

谢谢,

EN

回答 1

Stack Overflow用户

发布于 2015-01-31 05:54:19

它可以是新服务器上的.NET信任级别。尝试将该应用程序的IIS管理器中的信任级别设置为“完全”。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28245060

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档