public TRunner KillProcess(string processName) { KillProcessTask.Execute(scriptExecutionEnvironment, processName); return(ReturnThisTRunner()); }
/// <summary> /// Static method to generate an example configuration as file or string /// </summary> /// <param name="file">File name of the demo configuration</param> /// <param name="type">Task type of the demo configuration</param> /// <param name="asFile">If true a file will be generated, otherwise a string returned</param> private static string CreateDemoFile(string file, TaskType type, bool asFile) { Task t = new Task(); t.TaskName = "Demo-Task"; t.Description = "This is a demo Task with several sub-tasks of the type " + type.ToString(); t.Type = type; SubTask tb = null; SubTask t1, t2, t3; if (type == TaskType.DeleteFile) { tb = new DeleteFileTask(); } else if (type == TaskType.DeleteRegKey) { tb = new DeleteRegKeyTask(); } else if (type == TaskType.StartProgram) { tb = new StartProgramTask(); } else if (type == TaskType.WriteLog) { tb = new WriteLogTask(); } else if (type == TaskType.ControlService) { tb = new ControlServiceTask(); } else if (type == TaskType.KillProcess) { tb = new KillProcessTask(); } else if (type == TaskType.MetaTask) { tb = new MetaTask(); } t1 = tb.GetDemoFile(1); t2 = tb.GetDemoFile(2); t3 = tb.GetDemoFile(3); t3.UseParameter = true; t3.MainValue = "PARAM_NAME_1"; t3.Description = t3.Description + ". This Sub-Tasks uses a value of a global Parameter (passed as flag -p|--param) with the parameter name PARAM_NAME_1"; t.Items.Add(t1); t.Items.Add(t2); t.Items.Add(t3); if (asFile == true) { t.Serialize(file); return(""); } else { try { MemoryStream ms = t.SerializeAsStream(); StreamReader sr = new StreamReader(ms); string output = sr.ReadToEnd(); ms.Close(); ms.Dispose(); return(output); } catch (Exception e) { System.Console.WriteLine("Error while loading demo file as string\n" + e.Message); return(""); } } }