public static void Invoke(string aScript, RunningProcesses runningProcesses)
        {
            Process process = new Process();

            try
            {
                process.StartInfo = new ProcessStartInfo()
                {
                    FileName = $"{Environment.SystemDirectory}\\{ScriptConstants.kPowerShellPath}",
                    RedirectStandardError  = true,
                    RedirectStandardOutput = true,
                    CreateNoWindow         = true,
                    UseShellExecute        = false,
                    Arguments = aScript,
                };
                process.StartInfo.EnvironmentVariables["Path"] = CreatePathEnvironmentVariable();

                var customTidyExecutable = GetCustomTidyPath();

                if (string.IsNullOrWhiteSpace(customTidyExecutable) == false)
                {
                    process.StartInfo.EnvironmentVariables[ScriptConstants.kEnvrionmentTidyPath] = customTidyExecutable;
                }

                process.EnableRaisingEvents = true;
                process.ErrorDataReceived  += DataErrorHandler;
                process.OutputDataReceived += DataHandler;
                process.Exited   += ExitedHandler;
                process.Disposed += ExitedHandler;

                runningProcesses.Add(process);

                process.Start();

                process.BeginErrorReadLine();
                process.BeginOutputReadLine();

                process.WaitForExit();
            }
            catch (Exception e)
            {
                process.EnableRaisingEvents = false;
                process.ErrorDataReceived  -= DataErrorHandler;
                process.OutputDataReceived -= DataHandler;
                process.Exited   -= ExitedHandler;
                process.Disposed -= ExitedHandler;

                process.Close();

                throw e;
            }
        }
        public static Process Invoke(string aScript, RunningProcesses aRunningProcesses)
        {
            Process process = new Process();

            try
            {
                process.StartInfo = new ProcessStartInfo()
                {
                    FileName = $"{Environment.SystemDirectory}\\{ScriptConstants.kPowerShellPath}",
                    RedirectStandardError  = true,
                    RedirectStandardOutput = true,
                    CreateNoWindow         = true,
                    UseShellExecute        = false,
                    Arguments = aScript,
                };
                process.StartInfo.EnvironmentVariables["Path"] = CreatePathEnvironmentVariable();

                process.EnableRaisingEvents = true;
                process.ErrorDataReceived  += DataErrorHandler;
                process.OutputDataReceived += DataHandler;
                process.Exited   += ExitedHandler;
                process.Disposed += ExitedHandler;

                aRunningProcesses.Add(process);

                process.Start();
                process.BeginErrorReadLine();
                process.BeginOutputReadLine();
                process.WaitForExit();
            }
            catch (Exception)
            {
            }
            finally
            {
                process.ErrorDataReceived  -= DataErrorHandler;
                process.OutputDataReceived -= DataHandler;
                process.Exited             -= ExitedHandler;
                process.EnableRaisingEvents = false;
                process.Close();
            }
            return(process);
        }
        protected void RunScript(string aCommandName, TidyOptions mTidyOptions = null, TidyChecks mTidyChecks = null)
        {
            mScriptBuilder = new ScriptBuiler();
            mScriptBuilder.ConstructParameters(mGeneralOptions, mTidyOptions, mTidyChecks,
                                               DTEObj, VsEdition, VsVersion);

            string solutionPath = DTEObj.Solution.FullName;

            mOutputManager = new OutputManager(DTEObj);
            InitPowerShell();
            ClearWindows(aCommandName);
            mOutputManager.AddMessage($"\n{OutputWindowConstants.kStart} {aCommandName}\n");
            foreach (var item in mItemsCollector.GetItems)
            {
                var script = mScriptBuilder.GetScript(item, solutionPath);
                if (!mCommandsController.Running)
                {
                    break;
                }

                var process = mPowerShell.Invoke(script);
                mRunningProcesses.Add(process);

                if (mOutputManager.MissingLlvm)
                {
                    mOutputManager.AddMessage(ErrorParserConstants.kMissingLlvmMessage);
                    break;
                }
            }
            if (!mOutputManager.EmptyBuffer)
            {
                mOutputManager.AddMessage(String.Join("\n", mOutputManager.Buffer));
            }
            if (!mOutputManager.MissingLlvm)
            {
                mOutputManager.Show();
                mOutputManager.AddMessage($"\n{OutputWindowConstants.kDone} {aCommandName}\n");
            }
            if (mOutputManager.HasErrors)
            {
                mErrorsManager.AddErrors(mOutputManager.Errors);
            }
        }