zoukankan      html  css  js  c++  java
  • c# 调用外部程序的例子

     

    #region 一个调用外部程序的例子
      private static string CmdPing(string strIp)
      {
       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 pingrst;
       p.Start();
       p.StandardInput.WriteLine("telnet 192.168.3.175 9944");
       p.StandardInput.WriteLine("quit");
       p.StandardInput.WriteLine("exit");
       string strRst = p.StandardOutput.ReadToEnd();
       Trace.WriteLine(strRst);
       p.Close();
       return pingrst;
       }
    #endregion

    习惯改为;private static string Cmd(string strcmd)
    {
     Process p = new Process();
     p.StartInfo.FileName = "cmd.exe /c"+strcmd;
     p.StartInfo.UseShellExecute = false;
     p.StartInfo.RedirectStandardInput = true;
     p.StartInfo.RedirectStandardOutput = true;
     p.StartInfo.RedirectStandardError = true;
     p.StartInfo.CreateNoWindow = true;
     p.Start();www.shengfang.org
     string strRst = p.StandardOutput.ReadToEnd();
     System.Diagnostics.Trace.WriteLine(strRst);
     p.Close();
     return strRst;
    }

  • 相关阅读:
    imac 截图

    [Python] 安装及环境配置
    冒泡算法
    [转载]分页+双向排序(jquery + ashx)
    【转载】jQuery最佳实践
    【转载】星级评分jQuery插件
    ie浏览器模式判断语句
    jQuery面向对象定制业务框架开发
    【转载】jQuery设计思想
  • 原文地址:https://www.cnblogs.com/asyuras/p/278405.html
Copyright © 2011-2022 走看看