• .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#不能操作的内容啦.................
  • 相关阅读:
    Cookie
    laydate
    layer
    字符流
    java虚拟机学习(四)--垃圾收集算法
    java虚拟机学习(三)
    java虚拟机学习(二)
    java虚拟机学习(一)
    Mybatis学习(一)
    mysql数据库面试总结(一)
  • 原文地址:https://www.cnblogs.com/NatureSex/p/2014098.html
Copyright © 2020-2023  润新知