Example #1
0
        /// <summary>
        /// Executes a <see cref="ShellCommand"/> replacing the placeholders with the specified value.
        /// </summary>
        /// <param name="command">The command to execute.</param>
        /// <param name="replacements">The placeholders and their values to replace them with.</param>
        public static void ExecuteCommand(ShellCommand command, IEnumerable <KeyValuePair <string, string> > replacements)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            try
            {
                Process.Start(command.ToProcessStartInfo(replacements));
            }
            catch (Exception ex)
            {
                DDLogManager.GetLogger(typeof(ShellExecutor)).LogException(ex);
                //For now we just alert the user; maybe someday we'll use something more sophisticated than a messagebox
                MessageBox.Show(string.Format("{0}\r\n[{1}]", ex.Message, ex.GetType().Name), Properties.Resources.shellexecutor_errorexecutecmd, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
 /// <summary>
 /// Executes a <see cref="ShellCommand"/>.
 /// </summary>
 /// <param name="command">The command to execute.</param>
 public static void ExecuteCommand(ShellCommand command)
 {
     ExecuteCommand(command, null);
 }