| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 执行命令 |
| | | /// </summary> |
| | | /// <param name="list">命令集合</param> |
| | | public static string ExecCmdForWin(List<string> list, bool noWin = false) |
| | | { |
| | | string str = null; |
| | | Process p = null; |
| | | try |
| | | { |
| | | p = new Process(); |
| | | p.StartInfo.FileName = "cmd.exe"; |
| | | p.StartInfo.UseShellExecute = false; |
| | | p.StartInfo.CreateNoWindow = noWin; |
| | | p.StartInfo.RedirectStandardInput = true; |
| | | p.StartInfo.RedirectStandardOutput = true; |
| | | p.StartInfo.RedirectStandardError = true; |
| | | p.Start(); |
| | | |
| | | StreamWriter si = p.StandardInput; |
| | | StreamReader se = p.StandardError; |
| | | |
| | | LogOut.Info("cmd = " + string.Join(",", list)); |
| | | si.AutoFlush = true; |
| | | foreach (string cmd in list) |
| | | { |
| | | si.WriteLine(cmd); |
| | | } |
| | | si.WriteLine("exit"); |
| | | |
| | | str = se.ReadToEnd(); |
| | | se.Close(); |
| | | si.Close(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogOut.Error(ex.Message + "\r\n" + ex.StackTrace); |
| | | str = ex.Message; |
| | | } |
| | | finally |
| | | { |
| | | if (p != null) |
| | | { |
| | | p.Close(); |
| | | } |
| | | } |
| | | return str; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 创建数据发布类 |
| | | /// </summary> |
| | | public static SysPublish NewPublish(SysMeta meta, XYZArgs args, string url, string path) |