Beispiel #1
0
        static void Main(string[] args)
        {
            try
            {
                var installOffice = new InstallOffice();
                installOffice.RunProgram();

                var xmlConfiguration = "";

                var cmdArgs = CmdArguments.GetArguments();
                var xmlArg  = cmdArgs.FirstOrDefault(a => a.Name.ToUpper() == "XML");
                if (xmlArg != null)
                {
                    xmlConfiguration = xmlArg.Value;
                }

                Console.WriteLine("Office 365 ProPlus Install Executable Generator");
                Console.WriteLine();

                if (string.IsNullOrEmpty(xmlConfiguration))
                {
                    Console.Write("Configuration Xml File Path: ");
                    xmlConfiguration = Console.ReadLine();
                    Console.WriteLine();
                }

                if (!File.Exists(xmlConfiguration))
                {
                    throw (new Exception("File Does Not Exist: " + xmlConfiguration));
                }

                var p = new OfficeInstallMsiGenerator();
                p.Generate(new OfficeInstallProperties()
                {
                    OfficeVersion        = OfficeVersion.Office2016,
                    ConfigurationXmlPath = xmlConfiguration,
                    SourceFilePath       = null
                });
            }
            catch (Exception ex)
            {
                var backColor = Console.BackgroundColor;
                var textColor = Console.ForegroundColor;

                Console.BackgroundColor = ConsoleColor.Red;
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("ERROR: " + ex.Message);
                Console.BackgroundColor = backColor;
                Console.ForegroundColor = textColor;
            }
            finally
            {
                Console.WriteLine();
                Console.WriteLine("Done");
                Console.ReadLine();
            }
        }
        static void Main(string[] args)
        {

            try
            {
                var installOffice = new InstallOffice();
                installOffice.RunProgram();

                var xmlConfiguration = "";

                var cmdArgs = CmdArguments.GetArguments();
                var xmlArg = cmdArgs.FirstOrDefault(a => a.Name.ToUpper() == "XML");
                if (xmlArg != null) xmlConfiguration = xmlArg.Value;

                Console.WriteLine("Office 365 ProPlus Install Executable Generator");
                Console.WriteLine();

                if (string.IsNullOrEmpty(xmlConfiguration))
                {
                    Console.Write("Configuration Xml File Path: ");
                    xmlConfiguration = Console.ReadLine();
                    Console.WriteLine();
                }

                if (!File.Exists(xmlConfiguration))
                {
                    throw (new Exception("File Does Not Exist: " + xmlConfiguration));
                }

                var p = new OfficeInstallMsiGenerator();
                p.Generate(new OfficeInstallProperties()
                {
                    OfficeVersion = OfficeVersion.Office2016,
                    ConfigurationXmlPath = xmlConfiguration,
                    SourceFilePath = null
                });
            }
            catch (Exception ex)
            {
                var backColor = Console.BackgroundColor;
                var textColor = Console.ForegroundColor;

                Console.BackgroundColor = ConsoleColor.Red;
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("ERROR: " + ex.Message);
                Console.BackgroundColor = backColor;
                Console.ForegroundColor = textColor;
            }
            finally
            {
                Console.WriteLine();
                Console.WriteLine("Done");
                Console.ReadLine();
            }
        }
 public static void Main1(string[] args)
 {
     try
     {
         var install = new InstallOffice();
         install.RunProgram();
     }
     catch (Exception ex)
     {
         Console.WriteLine("ERROR: " + ex.ToString());
     }
     finally
     {
         Console.WriteLine();
     }
 }
 public static void Main1(string[] args)
 {
     try
     {
         var install = new InstallOffice();
         install.RunProgram();
     }
     catch (Exception ex)
     {
         Console.WriteLine("ERROR: " + ex.ToString());
     }
     finally
     {
         Console.WriteLine();
     }
 }
        static void Main(string[] args)
        {
            try
            {
                var productId = ""; //args[0];

                var officeInstall = new InstallOffice {ProductId = productId };
                officeInstall.IsLanguageInstalled(@"E:\Users\rsmith.VCG\Desktop\config1.xml", "en-us");
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR: " + ex.Message);
            }
            finally
            {
                Console.WriteLine("Done");
                Console.ReadLine();
            }
        }
 public static void Main1(string[] args)
 {
     using (var sw = new StreamWriter(@"C:\OfficeExeLog.txt"))
     {
         try
         {
             var install = new InstallOffice();
             install.RunProgram();
         }
         catch (Exception ex)
         {
             Console.WriteLine("ERROR: " + ex.ToString());
         }
         finally
         {
             Console.WriteLine();
         }
     }
 }
Beispiel #7
0
        static void Main(string[] args)
        {
            try
            {
                var productId = ""; //args[0];

                var officeInstall = new InstallOffice {
                    ProductId = productId
                };
                officeInstall.IsLanguageInstalled(@"E:\Users\rsmith.VCG\Desktop\config1.xml", "en-us");
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR: " + ex.Message);
            }
            finally
            {
                Console.WriteLine("Done");
                Console.ReadLine();
            }
        }
 public static void Main1(string[] args)
 {
     using (var sw = new StreamWriter(@"C:\OfficeExeLog.txt"))
     {
         
     
     try
     {
         var install = new InstallOffice();
         install.RunProgram();
     }
     catch (Exception ex)
     {
         Console.WriteLine("ERROR: " + ex.ToString());
     }
     finally
     {
         Console.WriteLine();
     }
     }
 }
        public async Task ChangeOfficeChannel()
        {
            await Task.Run(async () =>
            {
                var installOffice = new InstallOffice();
                try
                {
                    installOffice = new InstallOffice();
                    installOffice.UpdatingOfficeStatus += installOffice_UpdatingOfficeStatus;

                    var newChannel = "";
                    Dispatcher.Invoke(() =>
                    {
                        UpdateStatus.Content = "Updating...";
                        newChannel = ((OfficeBranch) ProductBranch.SelectedItem).NewName;
                        ChangeChannel.IsEnabled = false;
                        NewVersion.IsEnabled = false;
                    });

                    SetItemState(LocalViewItem.Update, LocalViewState.Wait);
                    
                    var ppDownloader = new ProPlusDownloader();
                    var baseUrl = await ppDownloader.GetChannelBaseUrlAsync(newChannel, OfficeEdition.Office32Bit);
                    if (string.IsNullOrEmpty(baseUrl))
                        throw (new Exception(string.Format("Cannot find BaseUrl for Channel: {0}", newChannel)));

                    var channelToChangeTo = "";
                    if (NewVersionRow.Visibility != Visibility.Visible)
                    {
                        channelToChangeTo =
                            await ppDownloader.GetLatestVersionAsync(newChannel, OfficeEdition.Office32Bit);
                    }
                    else
                    {
                        Dispatcher.Invoke(() =>
                        {
                            var manualVersion = NewVersion.Text;

                            if (string.IsNullOrEmpty(manualVersion) && NewVersion.SelectedItem != null)
                            {
                                manualVersion = ((Build)NewVersion.SelectedItem).Version;
                            }
                            if (!string.IsNullOrEmpty(manualVersion))
                            {
                                channelToChangeTo = manualVersion;
                            }
                        });
                    }

                    if (string.IsNullOrEmpty(channelToChangeTo))
                    {
                        throw (new Exception("Version required"));
                    }
                    else
                    {
                        if (!channelToChangeTo.IsValidVersion())
                        {
                            throw (new Exception(string.Format("Invalid Version: {0}", channelToChangeTo)));
                        }
                    }

                    await installOffice.ChangeOfficeChannel(channelToChangeTo, baseUrl);

                    Dispatcher.Invoke(() =>
                    {
                        UpdateStatus.Content = "";
                    });
                    
                    var installGenerator = new OfficeInstallManager();
                    LocalInstall = await installGenerator.CheckForOfficeInstallAsync();
                    if (LocalInstall.Installed)
                    {
                        Dispatcher.Invoke(() =>
                        {
                            VersionLabel.Content = LocalInstall.Version;
                            ChannelLabel.Content = LocalInstall.Channel;
                            ProductBranch.SelectedItem = LocalInstall.Channel;
                        });

                        if (LocalInstall.LatestVersionInstalled)
                        {
                            SetItemState(LocalViewItem.Update, LocalViewState.Success);
                        }
                        else
                        {
                            SetItemState(LocalViewItem.Update, LocalViewState.Action);
                            Dispatcher.Invoke(() =>
                            {
                                UpdateStatus.Content = "New version available  (" + LocalInstall.LatestVersion + ")";
                            });
                        }
                    }
                }
                catch (Exception ex)
                {
                    SetItemState(LocalViewItem.Update, LocalViewState.Fail);
                    Dispatcher.Invoke(() =>
                    {
                        UpdateStatus.Content = "The update failed";
                        ErrorText.Text = ex.Message;
                        RetryButtonColumn.Width = new GridLength(0, GridUnitType.Pixel);
                    });
                    LogErrorMessage(ex);
                }
                finally
                {
                    Dispatcher.Invoke(() =>
                    {
                        ChangeChannel.IsEnabled = true;
                        NewVersion.IsEnabled = true;
                    });
                }
            });
        }
        private async void ManageLocal()
        {
            try
            {
                if (_running) return;

                GlobalObjects.ViewModel.LocalConfig = true;
                GlobalObjects.ViewModel.BlockNavigation = true;
                _running = true;
                var localXml = "";

                await Task.Run(async () => {
                    Dispatcher.Invoke(() =>
                    {
                        WaitManageLocal.Visibility = Visibility.Visible;
                        //ImgManageLocal.Visibility = Visibility.Collapsed;
                    });

                    GlobalObjects.ViewModel.ApplicationMode = ApplicationMode.ManageLocal;

                    var officeInstallManager = new OfficeLocalInstallManager();
                    localXml = await officeInstallManager.GenerateConfigXml();
                });

                GlobalObjects.ViewModel.ConfigXmlParser.LoadXml(localXml);
                GlobalObjects.ViewModel.ResetXml = true;
                GlobalObjects.ViewModel.ImportFile = null;

                GlobalObjects.ViewModel.ConfigXmlParser.ConfigurationXml.Add.Version = null;

                if (RestartWorkflow != null)
                {
                    this.RestartWorkflow(this, new EventArgs());
                }

                GlobalObjects.ViewModel.BlockNavigation = false;

                var installOffice = new InstallOffice();
                if (installOffice.IsUpdateRunning())
                {
                    this.TransitionTab(this, new TransitionTabEventArgs()
                    {
                        Direction = TransitionTabDirection.Forward,
                        Index = 6,
                        UseIndex = true
                    });
                }
                else
                {
                    this.TransitionTab(this, new TransitionTabEventArgs()
                    {
                        Direction = TransitionTabDirection.Forward,
                        Index = 0
                    });
                }

                LogAnaylytics("/StartView", "StartNew");
            }
            catch (Exception ex)
            {
                LogErrorMessage(ex);
            }
            finally
            {
                Dispatcher.Invoke(() =>
                {
                    WaitManageLocal.Visibility = Visibility.Collapsed;
                    //ImgManageLocal.Visibility = Visibility.Visible;
                });
                _running = false;
            }
        }
        public async Task<string> GenerateConfigXml()
        {
            var currentDirectory = Directory.GetCurrentDirectory() + @"\Scripts";
            if (!System.IO.File.Exists(currentDirectory + @"\Generate-ODTConfigurationXML.ps1"))
            {
                currentDirectory = Directory.GetCurrentDirectory() + @"\Project\Scripts";
            }

            var xmlFilePath = Environment.ExpandEnvironmentVariables(@"%temp%\localConfig.xml");

            if (System.IO.File.Exists(xmlFilePath))
            {
                System.IO.File.Delete(xmlFilePath);
            }

            var scriptPath = currentDirectory + @"\Generate-ODTConfigurationXML.ps1";
            var scriptPathTmp = currentDirectory + @"\Tmp-Generate-ODTConfigurationXML.ps1";

            if (!System.IO.File.Exists(scriptPathTmp))
            {
                System.IO.File.Copy(scriptPath, scriptPathTmp, true);
            }

            var scriptUrl = AppSettings.GenerateScriptUrl;

            try
            {
                await Retry.BlockAsync(5, 1, async () =>
                {
                    using (var webClient = new WebClient())
                    {
                        await webClient.DownloadFileTaskAsync(new Uri(scriptUrl), scriptPath);
                    }
                });
            }
            catch (Exception ex) { }

            var n = 1;
            await Retry.BlockAsync(2, 1, async () =>
            {
                var arguments = @"/c Powershell -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle " +
                                @"Hidden -File .\RunGenerateXML.ps1";

                if (n == 2)
                {
                    System.IO.File.Copy(scriptPathTmp, scriptPath, true);
                }

                var p = new Process
                {
                    StartInfo = new ProcessStartInfo()
                    {
                        FileName = "cmd",
                        Arguments = arguments,
                        CreateNoWindow = true,
                        UseShellExecute = false,
                        WorkingDirectory = currentDirectory,
                        RedirectStandardOutput = true,
                        RedirectStandardError = true
                    },
                };

                p.Start();
                p.WaitForExit();

                var error = await p.StandardError.ReadToEndAsync();
                if (!string.IsNullOrEmpty(error)) throw (new Exception(error));
                n++;
            });

            await Task.Delay(100);

            var configXml = "";

            if (System.IO.File.Exists(xmlFilePath))
            {
                configXml = System.IO.File.ReadAllText(xmlFilePath);
            }

            try
            {
                var installOffice = new InstallOffice();
                var updateUrl = installOffice.GetBaseCdnUrl();
                if (!string.IsNullOrEmpty(updateUrl))
                {
                    var pd = new ProPlusDownloader();
                    var channelName = await pd.GetChannelNameFromUrlAsync(updateUrl, OfficeEdition.Office32Bit);
                    if (!string.IsNullOrEmpty(configXml) && !string.IsNullOrEmpty(channelName))
                    {
                        configXml = installOffice.SetUpdateChannel(configXml, channelName);
                    }
                }
            } catch { }

            return configXml;
        }
        private async void ManageLocal()
        {
            try
            {
                if (_running)
                {
                    return;
                }

                GlobalObjects.ViewModel.LocalConfig     = true;
                GlobalObjects.ViewModel.BlockNavigation = true;
                _running = true;
                var localXml = "";

                await Task.Run(async() => {
                    Dispatcher.Invoke(() =>
                    {
                        WaitManageLocal.Visibility = Visibility.Visible;
                        //ImgManageLocal.Visibility = Visibility.Collapsed;
                    });

                    GlobalObjects.ViewModel.ApplicationMode = ApplicationMode.ManageLocal;

                    var officeInstallManager = new OfficeLocalInstallManager();
                    localXml = await officeInstallManager.GenerateConfigXml();
                });

                GlobalObjects.ViewModel.ConfigXmlParser.LoadXml(localXml);
                GlobalObjects.ViewModel.ResetXml   = true;
                GlobalObjects.ViewModel.ImportFile = null;

                GlobalObjects.ViewModel.ConfigXmlParser.ConfigurationXml.Add.Version = null;

                if (RestartWorkflow != null)
                {
                    this.RestartWorkflow(this, new EventArgs());
                }

                GlobalObjects.ViewModel.BlockNavigation = false;

                var installOffice = new InstallOffice();
                if (installOffice.IsUpdateRunning())
                {
                    this.TransitionTab(this, new TransitionTabEventArgs()
                    {
                        Direction = TransitionTabDirection.Forward,
                        Index     = 6,
                        UseIndex  = true
                    });
                }
                else
                {
                    this.TransitionTab(this, new TransitionTabEventArgs()
                    {
                        Direction = TransitionTabDirection.Forward,
                        Index     = 0
                    });
                }

                LogAnaylytics("/StartView", "StartNew");
            }
            catch (Exception ex)
            {
                LogErrorMessage(ex);
            }
            finally
            {
                Dispatcher.Invoke(() =>
                {
                    WaitManageLocal.Visibility = Visibility.Collapsed;
                    //ImgManageLocal.Visibility = Visibility.Visible;
                });
                _running = false;
            }
        }
 public async Task UpdateOffice()
 {
     var installOffice = new InstallOffice();
 }
 public async Task UpdateOffice()
 {
     var installOffice = new InstallOffice();
    
 }
        public async Task RunUpdateOffice()
        {
            await Task.Run(async () =>
            {
                InstallOffice installOffice = null;
                try
                {
                    installOffice = new InstallOffice();
                    installOffice.UpdatingOfficeStatus += installOffice_UpdatingOfficeStatus;

                    Dispatcher.Invoke(() =>
                    {
                        UpdateStatus.Content = "Updating...";
                        ShowVersion.IsEnabled = false;
                        ChangeChannel.IsEnabled = false;
                    });

                    GlobalObjects.ViewModel.BlockNavigation = true;

                    SetItemState(LocalViewItem.Update, LocalViewState.Wait);

                    var currentChannel = LocalInstall.Channel;
                    if (!installOffice.IsUpdateRunning())
                    {
                        var ppDownloader = new ProPlusDownloader();
                        var baseUrl =
                            await ppDownloader.GetChannelBaseUrlAsync(currentChannel, OfficeEdition.Office32Bit);
                        if (string.IsNullOrEmpty(baseUrl))
                            throw (new Exception(string.Format("Cannot find BaseUrl for Channel: {0}", currentChannel)));

                        installOffice.ChangeUpdateSource(baseUrl);
                    }

                    SetSelectedVersion();

                    await installOffice.RunOfficeUpdateAsync(LocalInstall.LatestVersion);
                    
                    Dispatcher.Invoke(() =>
                    {
                        UpdateStatus.Content = "";
                    });

                    var installGenerator = new OfficeInstallManager(); 
                    LocalInstall = await installGenerator.CheckForOfficeInstallAsync();
                    if (LocalInstall.Installed)
                    {
                        Dispatcher.Invoke(() =>
                        {
                            VersionLabel.Content = LocalInstall.Version;
                            ChannelLabel.Content = LocalInstall.Channel;
                            ProductBranch.SelectedItem = LocalInstall.Channel;
                        });

                        if (LocalInstall.LatestVersionInstalled)
                        {
                            SetItemState(LocalViewItem.Update, LocalViewState.Success);
                        }
                        else
                        {
                            SetItemState(LocalViewItem.Update, LocalViewState.Action);
                            Dispatcher.Invoke(() =>
                            {
                                UpdateStatus.Content = "New version available  (" + LocalInstall.LatestVersion + ")";
                            });
                        }
                    }
                }
                catch (Exception ex)
                {
                    SetItemState(LocalViewItem.Update, LocalViewState.Fail);
                    Dispatcher.Invoke(() =>
                    {
                        UpdateStatus.Content = "The update failed";
                        ErrorText.Text = ex.Message;
                    });

                    LogErrorMessage(ex);
                }
                finally
                {
                    installOffice.ResetUpdateSource();
                    Dispatcher.Invoke(() =>
                    {
                        ShowVersion.IsEnabled = true;
                        ChangeChannel.IsEnabled = true;
                    });
                    GlobalObjects.ViewModel.BlockNavigation = false;
                }
            });
        }
        private async Task LoadViewState()
        {
            try
            {
                await Retry.BlockAsync(10, 1, async () => {
                    Dispatcher.Invoke(() =>
                    {
                       ErrorRow.Visibility = Visibility.Collapsed;
                    });

                    SetItemState(LocalViewItem.Install, LocalViewState.Default);

                    var installGenerator = new OfficeLocalInstallManager(); 
                    LocalInstall = await installGenerator.CheckForOfficeInstallAsync();

                    if (LocalInstall.Installed)
                    {
                        SetItemState(LocalViewItem.Install, LocalViewState.Success);
                        SetItemState(LocalViewItem.Uninstall, LocalViewState.Action);

                        Dispatcher.Invoke(() =>
                        {
                            VersionLabel.Content = "(" + LocalInstall.Version + ")";
                            ChannelLabel.Content = LocalInstall.Channel;

                           // ChannelLabel.Content = "First Release Deferred";

                            if (ChannelLabel.Content.ToString().Length < 10)
                            {
                                ChannelName.Width = new GridLength(100);
                            }
                            else if (ChannelLabel.Content.ToString().Length < 20)
                            {
                                ChannelName.Width = new GridLength(150);
                            }
                            else 
                            {
                                ChannelName.Width = new GridLength(200);
                            }

                            var selectIndex = 0;
                            if (LocalInstall.Channel != null)
                            {
                                for (var i = 0; i < ProductBranch.Items.Count; i++)
                                {
                                    var item = (OfficeBranch) ProductBranch.Items[i];
                                    if (item == null) continue;
                                    if (item.NewName.ToLower() != LocalInstall.Channel.ToLower()) continue;
                                    selectIndex = i;
                                    break;
                                }
                            }

                            BranchChanged(this, new BranchChangedEventArgs()
                            {
                                BranchName = LocalInstall.Channel
                            });

                            ProductBranch.SelectedIndex = selectIndex;
                        });

                        var installOffice = new InstallOffice();
                        if (installOffice.IsUpdateRunning())
                        {
                            await RunUpdateOffice();
                        }
                        else
                        {
                            if (LocalInstall.LatestVersionInstalled)
                            {
                                SetItemState(LocalViewItem.Update, LocalViewState.Success);
                            }
                            else
                            {
                                SetItemState(LocalViewItem.Update, LocalViewState.Action);
                                Dispatcher.Invoke(() =>
                                {
                                    UpdateStatus.Content = "New version available  (" + LocalInstall.LatestVersion + ")";
                                });
                            }
                        }

                        Dispatcher.Invoke(() =>
                        {
                            ChangeChannel.IsEnabled = false;
                        });
                    }
                    else
                    {
                        SetItemState(LocalViewItem.Install, LocalViewState.Action);
                    }
                });
            }
            catch (Exception ex)
            {
                SetItemState(LocalViewItem.Install, LocalViewState.Fail);
                Dispatcher.Invoke(() =>
                {
                    ErrorText.Text = ex.Message;
                });
                LogErrorMessage(ex);
            }
        }
        private void RemoveSelectedLanguage()
        {
            var selectProductId = GetSelectedProduct();
            var installOffice = new InstallOffice();

            var currentItems = (List<Language>)LanguageList.ItemsSource ?? new List<Language>();
            foreach (Language language in LanguageList.SelectedItems)
            {
                if (currentItems.Contains(language))
                {
                    currentItems.Remove(language);
                }

                GlobalObjects.ViewModel.RemoveLanguage(selectProductId, language.Id);

                if (!GlobalObjects.ViewModel.LocalConfig) continue;

                var productId = language.ProductId;
                if (string.IsNullOrEmpty(productId)) productId = "O365ProPlusRetail";

                var languageInstalled = installOffice.ProPlusLanguageInstalled(productId, language.Id);
                if (languageInstalled)
                {
                    GlobalObjects.ViewModel.AddRemovedLanguage(productId, language);
                }
            }

            LanguageList.ItemsSource = null;
            LanguageList.ItemsSource = GlobalObjects.ViewModel.GetLanguages(selectProductId);

            UpdateXml();
        }
        public async Task <string> GenerateConfigXml()
        {
            var currentDirectory = Directory.GetCurrentDirectory() + @"\Scripts";

            if (!System.IO.File.Exists(currentDirectory + @"\Generate-ODTConfigurationXML.ps1"))
            {
                currentDirectory = Directory.GetCurrentDirectory() + @"\Project\Scripts";
            }

            var xmlFilePath = Environment.ExpandEnvironmentVariables(@"%temp%\localConfig.xml");

            if (System.IO.File.Exists(xmlFilePath))
            {
                System.IO.File.Delete(xmlFilePath);
            }

            var scriptPath    = currentDirectory + @"\Generate-ODTConfigurationXML.ps1";
            var scriptPathTmp = currentDirectory + @"\Tmp-Generate-ODTConfigurationXML.ps1";

            if (!System.IO.File.Exists(scriptPathTmp))
            {
                System.IO.File.Copy(scriptPath, scriptPathTmp, true);
            }

            var scriptUrl = AppSettings.GenerateScriptUrl;

            try
            {
                await Retry.BlockAsync(5, 1, async() =>
                {
                    using (var webClient = new WebClient())
                    {
                        await webClient.DownloadFileTaskAsync(new Uri(scriptUrl), scriptPath);
                    }
                });
            }
            catch (Exception ex) { }

            var n = 1;
            await Retry.BlockAsync(2, 1, async() =>
            {
                var arguments = @"/c Powershell -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle " +
                                @"Hidden -File .\RunGenerateXML.ps1";

                if (n == 2)
                {
                    System.IO.File.Copy(scriptPathTmp, scriptPath, true);
                }

                var p = new Process
                {
                    StartInfo = new ProcessStartInfo()
                    {
                        FileName               = "cmd",
                        Arguments              = arguments,
                        CreateNoWindow         = true,
                        UseShellExecute        = false,
                        WorkingDirectory       = currentDirectory,
                        RedirectStandardOutput = true,
                        RedirectStandardError  = true
                    },
                };

                p.Start();
                p.WaitForExit();

                var error = await p.StandardError.ReadToEndAsync();
                if (!string.IsNullOrEmpty(error))
                {
                    throw (new Exception(error));
                }
                n++;
            });

            await Task.Delay(100);

            var configXml = "";

            if (System.IO.File.Exists(xmlFilePath))
            {
                configXml = System.IO.File.ReadAllText(xmlFilePath);
            }

            try
            {
                var installOffice = new InstallOffice();
                var updateUrl     = installOffice.GetBaseCdnUrl();
                if (!string.IsNullOrEmpty(updateUrl))
                {
                    var pd          = new ProPlusDownloader();
                    var channelName = await pd.GetChannelNameFromUrlAsync(updateUrl, OfficeEdition.Office32Bit);

                    if (!string.IsNullOrEmpty(configXml) && !string.IsNullOrEmpty(channelName))
                    {
                        configXml = installOffice.SetUpdateChannel(configXml, channelName);
                    }
                }
            } catch { }

            return(configXml);
        }