示例#1
0
        public static int execute(
            string command,
            IFileSystem fileSystem,
            int waitForExitSeconds,
            Action <object, DataReceivedEventArgs> stdOutAction,
            Action <object, DataReceivedEventArgs> stdErrAction
            )
        {
            if (string.IsNullOrWhiteSpace(_powershell))
            {
                _powershell = get_powershell_location(fileSystem);
            }
            //-NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%DIR%chocolatey.ps1' %PS_ARGS%"
            string arguments = "-NoProfile -NoLogo -ExecutionPolicy Bypass -Command \"{0}\"".format_with(command);

            return(CommandExecutor.execute_static(
                       _powershell,
                       arguments,
                       waitForExitSeconds,
                       workingDirectory: fileSystem.get_directory_name(fileSystem.get_current_assembly_path()),
                       stdOutAction: stdOutAction,
                       stdErrAction: stdErrAction,
                       updateProcessPath: true,
                       allowUseWindow: _allowUseWindow
                       ));
        }