zoukankan      html  css  js  c++  java
  • .Net程序操作CMD命令

     使用代码操作CMD命令行程序
    public void ExecuteCmd(string cmd)
    {
                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;
                p.Start();
                //设置自动刷新缓冲并更新
                p.StandardInput.AutoFlush = true;
                //写入命令
                p.StandardInput.WriteLine(cmd);
                p.StandardInput.WriteLine("exit");
                //等待结束
                p.WaitForExit();
                p.Close();
     }
    
    
    
    OK!有了这个就可以执行一些C#不能操作的内容啦.................
  • 相关阅读:
    前端的缓存
    微信开发小程序Taro框架
    前端必会的Nginx
    微信开发小程序
    如何进行有效的沟通
    产品经理和项目经理的区别
    Django之模板
    Django之视图
    Django之路由系统
    创建一个简单的Django项目
  • 原文地址:https://www.cnblogs.com/NatureSex/p/2014098.html
Copyright © 2011-2022 走看看