zoukankan      html  css  js  c++  java
  • APS.NET 打开cmd

     1  #region 连接文件库
     2         private static void ConnectServer(String sServerPath, String sUserName, String sUserPwd)
     3         {
     4             ProcessStartInfo psi = new ProcessStartInfo();
     5             Process proc = new Process();
     6             psi.FileName = "cmd.exe";
     7             psi.RedirectStandardInput = true;
     8             psi.RedirectStandardOutput = true;
     9             psi.CreateNoWindow = true;
    10             psi.UseShellExecute = false;
    11             proc = Process.Start(psi);
    12             proc.StandardInput.WriteLine("net use " + sServerPath + " /del");
    13             Thread.Sleep(500);
    14             proc.StandardInput.WriteLine("net use " + sServerPath + " /user:" + sUserName + " " + sUserPwd);
    15             Thread.Sleep(500);
    16             proc.StandardInput.WriteLine("exit");
    17             String result = proc.StandardOutput.ReadToEnd();
    18             proc.Close();
    19             proc.Dispose();
    20 
    21         }
    22 
    23         private static void CloseServer(string sServerPath)
    24         {
    25             ProcessStartInfo psi = new ProcessStartInfo();
    26             Process proc = new Process();
    27             psi.FileName = "cmd.exe";
    28             psi.RedirectStandardInput = true;
    29             psi.RedirectStandardOutput = true;
    30             psi.CreateNoWindow = true;
    31             psi.UseShellExecute = false;
    32             proc = Process.Start(psi);
    33             proc.StandardInput.WriteLine("net use " + sServerPath + " /del");
    34             Thread.Sleep(500);
    35             proc.StandardInput.WriteLine("exit");
    36             String result = proc.StandardOutput.ReadToEnd();
    37             proc.Close();
    38             proc.Dispose();
    39 
    40         }
    41         #endregion

    ---恢复内容结束---

  • 相关阅读:
    scala-for高级用法
    scala-for
    numpy每行,没列中的最小值
    NLP
    sql-server笔记-sql
    openlayers加载geoserver的WMS服务出现点标注显示不全
    oracle删除表
    idea-debug
    python-windows安装相关问题
    mybatis-oracle 新增序列
  • 原文地址:https://www.cnblogs.com/wxc-kingsley/p/3460868.html
Copyright © 2011-2022 走看看