public override void Run(Dictionary <String, Parameter> RunParams) { string Parameters = null; DCOM.DCOMMethod Method = DCOM.DCOMMethod.MMC20_Application; if (RunParams.TryGetValue("Parameters", out Parameter parameters)) { Parameters = parameters.Value[0]; } if (RunParams.TryGetValue("Method", out Parameter method)) { string value = method.Value[0]; switch (value) { case "MMC20": Method = DCOM.DCOMMethod.MMC20_Application; break; case "ShellWindow": Method = DCOM.DCOMMethod.ShellWindows; break; case "ShellBrowserWindow": Method = DCOM.DCOMMethod.ShellBrowserWindow; break; case "ExcelDDE": Method = DCOM.DCOMMethod.ExcelDDE; break; default: Printing.Error($"{value} is not a valid method"); break; } } if (RunParams.TryGetValue("ComputerName", out Parameter computer)) { if (RunParams.TryGetValue("Command", out Parameter command)) { foreach (string cmd in command.Value) { DCOM.DCOMExecute(computer.Value, cmd, Parameters, null, Method); } } else { Printing.Error("No command specified"); } } else { Printing.Error("No Computer Name specified."); } }
public void TestDCOMExecute() { Assert.IsTrue(DCOM.DCOMExecute("localhost", "calc.exe", "", "C:\\WINDOWS\\System32\\", DCOM.DCOMMethod.MMC20_Application)); Assert.IsTrue(System.Diagnostics.Process.GetProcessesByName("Calculator").Length >= 1); Assert.IsTrue(DCOM.DCOMExecute("localhost", "calc.exe", "", "C:\\WINDOWS\\System32\\", DCOM.DCOMMethod.ShellBrowserWindow)); Assert.IsTrue(System.Diagnostics.Process.GetProcessesByName("Calculator").Length >= 2); Assert.IsTrue(DCOM.DCOMExecute("localhost", "calc.exe", "", "C:\\WINDOWS\\System32\\", DCOM.DCOMMethod.ShellWindows)); Assert.IsTrue(System.Diagnostics.Process.GetProcessesByName("Calculator").Length >= 3); Assert.IsTrue(DCOM.DCOMExecute("localhost", "calc.exe", "", "C:\\WINDOWS\\System32\\", DCOM.DCOMMethod.ExcelDDE)); Assert.IsTrue(System.Diagnostics.Process.GetProcessesByName("Calculator").Length >= 4); }