• 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

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

  • 相关阅读:
    批处理实现SQLServer数据库备份与还原
    Axapta物流模块深度历险(二)
    Axapta4.0Tech
    Script#
    Axapta物流模块深度历险(一)
    Agrs Class
    折半的意义
    个人性格
    诚实
    英语学习闪存
  • 原文地址:https://www.cnblogs.com/wxc-kingsley/p/3460868.html
Copyright © 2020-2023  润新知