static void ExecuteScripts(ScriptPackage package) { ScriptExecutor executor = new ScriptExecutor(); if (_selectedSwitches.HasFlag(Switches.Verbose)) executor.LogUpdated += new ScriptExecutor.LogChanged(executor_LogUpdated); else if (!_selectedSwitches.HasFlag(Switches.Verbose) && !_selectedSwitches.HasFlag(Switches.Quiet)) foreach (Script script in package.Scripts) script.StatusChanged += new Script.ScriptChange(script_StatusChanged); executor.ExecuteScripts(package.Scripts); while (executor.IsExecuting) Thread.Sleep(1000); foreach (Script script in package.Scripts) { if (script.Status == ScriptStatus.Disabled || script.Status == ScriptStatus.Executed) continue; Environment.ExitCode = 1; System.Console.WriteLine("One or more scripts failed to execute properly."); break; } }