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

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

  • 相关阅读:
    常用的标签分类
    css 实现动态二级菜单
    5大主流浏览器内核
    MySQL里面的子查询
    Algolia Search
    Nginx配置
    PHP中Abstract与Interface区别
    Shell 基本语法
    百度 echarts K线图使用
    php_soap扩展应用
  • 原文地址:https://www.cnblogs.com/wxc-kingsley/p/3460868.html
Copyright © 2011-2022 走看看