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);

  • 相关阅读:
    HttpClient
    充值保存
    button 样式
    创建窗口
    第十一次作业
    第十次作业
    第九次作业
    第八次作业
    第七次作业
    第六次作业
  • 原文地址:https://www.cnblogs.com/wenjie/p/3034861.html
Copyright © 2011-2022 走看看