async Task<Process> LaunchUpdaterProcess(LaunchGameInfoBase spec, ProcessStartInfo startInfo) {
            LogGameInfo(spec);
            LogStartupInfo(startInfo);
            var lInfo = new BasicLaunchInfo(startInfo);
            if (spec.WaitForExit)
                await (spec.LaunchAsAdministrator ? _processManager.LaunchElevatedAsync(lInfo) : _processManager.LaunchAsync(lInfo)).ConfigureAwait(false);
            else
                using (var p = spec.LaunchAsAdministrator ? _processManager.StartElevated(startInfo) : _processManager.Start(startInfo)) { }

            var procName = spec.ExpectedExecutable.FileNameWithoutExtension;
            return await FindGameProcess(procName).ConfigureAwait(false);
        }
        protected static async Task BuildAndRunBatFile(IProcessManager pm, IAbsoluteDirectoryPath tmpFolder,
            IEnumerable<string> commands, bool asAdministrator = false, bool noisy = false) {
            var batFile = tmpFolder.GetChildFileWithName("install.bat");
            var actualCommands =
                new[] {"chcp 65001"}.Concat(commands)
                    .Concat(new[] {"echo finished"})
                    .Select(x => x == "" ? x : x + " >> install.log");
            var commandBat = string.Join("\r\n",
                new[] {"", "echo starting > install.log"}.Concat(actualCommands)
                    .Concat(new[] {""}));
            var encoding = Encoding.UTF8;
            File.WriteAllText(batFile.ToString(), commandBat, encoding);
            if (Common.Flags.Verbose || noisy)
                MainLog.Logger.Info("install.bat content:\n" + commandBat);

            try {
                var pInfo = new ProcessStartInfoBuilder(batFile) {
                    WorkingDirectory = tmpFolder
                    //WindowStyle = ProcessWindowStyle.Minimized
                }.Build();
                pInfo.CreateNoWindow = true;
                var basicLaunchInfo = new BasicLaunchInfo(pInfo) {StartMinimized = true};
                var r =
                    await (asAdministrator ? pm.LaunchElevatedAsync(basicLaunchInfo) : pm.LaunchAsync(basicLaunchInfo));
                r.ConfirmSuccess();
            } catch (Win32Exception ex) {
                if (ex.IsElevationCancelled())
                    throw ex.HandleUserCancelled();
                throw;
            }
            var logFile = tmpFolder.GetChildFileWithName("install.log");
            var output = File.ReadAllText(logFile.ToString(), encoding);

            if (Common.Flags.Verbose || noisy)
                MainLog.Logger.Info("install.bat output:\n" + output);
        }
 public abstract Process Launch(BasicLaunchInfo info);
 public Task<ProcessExitResultWithOutput> LaunchAndGrabAsync(BasicLaunchInfo info) {
     Contract.Requires<ArgumentNullException>(info != null);
     return default(Task<ProcessExitResultWithOutput>);
 }
 public abstract Task<ProcessExitResult> LaunchElevatedAsync(BasicLaunchInfo info);
 public ProcessExitResultWithOutput LaunchAndGrab(BasicLaunchInfo info) {
     ProcessBLI(info);
     var outputBuilder = new StringBuilder();
     var errorBuilder = new StringBuilder();
     var outInfo = LaunchAndProcess(new LaunchAndProcessInfo(info.StartInfo.EnableRedirect()) {
         StandardOutputAction = (process, data) => outputBuilder.AppendLine(data),
         StandardErrorAction = (process, data) => errorBuilder.AppendLine(data),
         MonitorOutput = info.MonitorOutput,
         MonitorResponding = info.MonitorResponding
     });
     return new ProcessExitResultWithOutput(outInfo.ExitCode, outInfo.Id, info.StartInfo,
         outputBuilder.ToString(),
         errorBuilder.ToString());
 }
 private static void ProcessBLI(BasicLaunchInfo info) {
     //if (info.StartMinimized)
         //info.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
 }
 public ProcessExitResult LaunchElevated(BasicLaunchInfo info) {
     info.StartInfo.EnableRunAsAdministrator();
     ProcessBLI(info);
     using (var process = new Process {StartInfo = info.StartInfo}) {
         LaunchAndWaitForExit(process, info.MonitorOutput, info.MonitorResponding);
         return new ProcessExitResult(process.ExitCode, process.Id, info.StartInfo);
     }
 }
 public ProcessExitResult Launch(BasicLaunchInfo info) {
     ProcessBLI(info);
     using (var process = new Process {StartInfo = info.StartInfo}) {
         LaunchAndWaitForExit(process, info.MonitorOutput, info.MonitorResponding);
         return new ProcessExitResult(process.ExitCode, process.Id, info.StartInfo);
     }
 }
 public async Task<ProcessExitResult> LaunchElevatedAsync(BasicLaunchInfo info) {
     info.StartInfo.EnableRunAsAdministrator();
     ProcessBLI(info);
     using (var process = new ReactiveProcess {StartInfo = info.StartInfo}) {
         return
             await
                 LaunchAndWaitForExitAsync(process, info.MonitorOutput, info.MonitorResponding,
                         info.CancellationToken)
                     .ConfigureAwait(false);
     }
 }