zoukankan      html  css  js  c++  java
  • C#执行cmd [转载]

    网址:http://www.cnblogs.com/190196539/archive/2011/12/20/2294163.html

        string cmdtext = "net use u: \\\\192.168.0.44\\src \"" + user + "\" /user:" + pwd;
                Process MyProcess = new Process();
                //设定程序名
                MyProcess.StartInfo.FileName = "cmd.exe";
                //关闭Shell的使用
                MyProcess.StartInfo.UseShellExecute = false;
                //重定向标准输入
                MyProcess.StartInfo.RedirectStandardInput = true;
                //重定向标准输出
                MyProcess.StartInfo.RedirectStandardOutput = true;
                //重定向错误输出
                MyProcess.StartInfo.RedirectStandardError = true;
                //设置不显示窗口
                MyProcess.StartInfo.CreateNoWindow = true;
                //执行VER命令
                MyProcess.Start();
                MyProcess.StandardInput.WriteLine(cmdtext);
                MyProcess.StandardInput.WriteLine("exit");
                //从输出流获取命令执行结果,
                //string exepath = Application.StartupPath;
                //把返回的DOS信息读出来
                String StrInfo = MyProcess.StandardOutput.ReadToEnd();
                Console.WriteLine(StrInfo);

  • 相关阅读:
    自动生成接口文档
    Haystack全文搜索
    redis操作
    缓存及跨域问题
    url控制器、解析器、响应器、分页器
    频率组件
    序列化、认证、权限、视图回顾
    认证、权限、视图组件
    序列化组件
    Rest Framework
  • 原文地址:https://www.cnblogs.com/wenjie/p/3034861.html
Copyright © 2011-2022 走看看