private static SystemProcess Launch(string command, SystemProcessArguments commandParams, string path, bool redirectOutputs, bool?hidden, ProcessPriorityClass priority, string username, string domain, string password, Action <string> outHandle = null, Action <string> errHandle = null)
 {
     return(Launch(command, commandParams.ToString(), path, redirectOutputs, hidden, priority, username, domain, password, outHandle, errHandle));
 }
        public void Execute()
        {
            this.process           = new Process();
            this.process.StartInfo = new ProcessStartInfo(command, arguments == null ? inlineArguments : arguments.ToString());
            this.process.StartInfo.UseShellExecute = false;
            if (!hidden.HasValue || hidden == true)
            {
                this.process.StartInfo.WindowStyle    = ProcessWindowStyle.Minimized;
                this.process.StartInfo.CreateNoWindow = true;
            }
            if (hidden == true)
            {
                this.process.StartInfo.ErrorDialog = false;
            }
            if (this.redirectOutputs)
            {
                this.process.StartInfo.RedirectStandardOutput = true;
                this.process.StartInfo.RedirectStandardError  = true;
            }
            if (path != null)
            {
                this.process.StartInfo.WorkingDirectory = path;
            }

            this.process.StartInfo.UserName = username;
            this.process.StartInfo.Domain   = domain;
            if (!String.IsNullOrEmpty(password))
            {
                this.process.StartInfo.Password = new System.Security.SecureString();
                foreach (var c in password)
                {
                    this.process.StartInfo.Password.AppendChar(c);
                }
                this.process.StartInfo.Password.MakeReadOnly();
            }

            this.process.Start();
            this.process.PriorityClass = priority;
        }