Commit e0544dd645e128f6715b6782488b14a8d7f424ff

Authored by Schwirg László
1 parent 98324260

v1.12.0.0

adding menuitem procdump for services
Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - CommandLineParser.cs
... ... @@ -231,6 +231,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.CommandLineParserNS
231 231 public static class Start { public const string KEY = "WSS"; }
232 232 public static class Stop { public const string KEY = "WSX"; }
233 233 public static class Kill { public const string KEY = "WSK"; }
  234 + public static class Dump { public const string KEY = "DMP"; }
234 235 public static class Purge { public const string KEY = "WSP"; }
235 236 }
236 237 }
... ...
Vrh.Log4Pro.MaintenanceConsole/Manager - WindowsServiceManager.cs
... ... @@ -88,6 +88,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WindowsServiceManagerNS
88 88 .AddMenuItem(new Menu.Item(CLP.Module.WindowsServiceManager.Function.Start.KEY, "Start"))
89 89 .AddMenuItem(new Menu.Item(CLP.Module.WindowsServiceManager.Function.Stop.KEY, "Stop"))
90 90 .AddMenuItem(new Menu.Item(CLP.Module.WindowsServiceManager.Function.Kill.KEY, "Kill"))
  91 + .AddMenuItem(new Menu.Item(CLP.Module.WindowsServiceManager.Function.Dump.KEY, "Dump"))
91 92 .AddMenuItem(new Menu.Item(CLP.Module.WindowsServiceManager.Function.SetUserAccount.KEY, "Set user account"))
92 93 .SetSelectionMode(Menu.SelectionMode.Single)
93 94 ;
... ... @@ -147,6 +148,18 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WindowsServiceManagerNS
147 148 catch (Exception ex) { ColorConsole.WriteLine(ex.Message, ConsoleColor.Red); }
148 149 }
149 150 break;
  151 + case CLP.Module.WindowsServiceManager.Function.Dump.KEY:
  152 + foreach (var ws in selectedServices)
  153 + {
  154 + try
  155 + {
  156 + var success = WindowsServiceManagerCore.Dump(ws.Name);
  157 + ColorConsole.WriteLine($"Service dump completed. Name:{ws.Name}", ConsoleColor.Green);
  158 + }
  159 + catch (Exception ex) { ColorConsole.WriteLine(ex.Message, ConsoleColor.Red); }
  160 + }
  161 + break;
  162 + break;
150 163 case CLP.Module.WindowsServiceManager.Function.Kill.KEY:
151 164 foreach (var ws in selectedServices)
152 165 {
... ... @@ -437,7 +450,30 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WindowsServiceManagerNS
437 450 return true;
438 451 }
439 452 }
440   -
  453 +
  454 + public static bool Dump(string sname)
  455 + {
  456 + using (var wmiService = WindowsServiceManagerCore.GetServiceObject(sname))
  457 + {
  458 + string sstate = (string)wmiService[nameof(WindowsService.State)];
  459 + if (sstate != nameof(ObjectState.Stopped))
  460 + {
  461 + int pid = Convert.ToInt32(wmiService[nameof(WindowsService.ProcessId)]);
  462 + Process p = new Process();
  463 + p.StartInfo.FileName = "procdump.exe";
  464 + p.StartInfo.Arguments = $"-accepteula -ma -o {pid} .";
  465 + //p.StartInfo.FileName = "";
  466 + p.StartInfo.UseShellExecute = false;
  467 + p.StartInfo.RedirectStandardOutput = true;
  468 + p.Start();
  469 + string output = p.StandardOutput.ReadToEnd();
  470 + string logwaiting = "waiting.";
  471 + while (!p.HasExited) { logwaiting += "."; p.WaitForExit(); }
  472 + foreach (var dumpline in output.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries)) { ColorConsole.WriteLine(dumpline); ColorConsole.WriteLine(""); }
  473 + }
  474 + return true;
  475 + }
  476 + }
441 477 /// <summary>
442 478 /// Kill a process, and all of its children, grandchildren, etc.
443 479 /// </summary>
... ...
Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs
... ... @@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
32 32 // You can specify all the values or you can default the Build and Revision Numbers
33 33 // by using the '*' as shown below:
34 34 // [assembly: AssemblyVersion("1.0.*")]
35   -[assembly: AssemblyVersion("1.11.5.0")]
36   -[assembly: AssemblyFileVersion("1.11.5.0")]
  35 +[assembly: AssemblyVersion("1.12.0.0")]
  36 +[assembly: AssemblyFileVersion("1.12.0.0")]
... ...