Exemplo n.º 1
0
        /// <summary>
        /// Remove a Language from the Microsoft Office Installer
        /// </summary>
        /// <param name="languageName">Name of Language to Remove</param>
        public static void RemoveLanguagePack(string languageName)
        {
            if (InstallerInformation.Languages.Count > 1)
            {
                LanguageList languageList = new LanguageList();
                string       languageCode = languageList.GetLanguageCode(languageName);

                if (String.IsNullOrWhiteSpace(languageCode))
                {
                    throw new Exception("Failed to determine selected language and ending");
                }

                if (Directory.Exists(InstallerInformation.InstallerPath + "Office." + languageCode) == false)
                {
                    throw new Exception("This Language is not installed!");
                }
                foreach (string folder in Directory.GetDirectories(InstallerInformation.InstallerPath, "*." + languageCode))
                {
                    CommonUtilities.FolderDelete(folder);
                }

                InstallerInformation.Languages.Remove(languageName);
            }
            else
            {
                throw new Exception("You only have one language installed!");
            }
        }
Exemplo n.º 2
0
        public InstallerInfo(string installerPath)
        {
            Languages             = new List <string>();
            RetailProducts        = new List <string>();
            VolumeProducts        = new List <string>();
            InstallerArchitecture = string.Empty;
            InstallerPath         = installerPath;
            SetupVersionMajor     = 0;
            SetupVersionFull      = string.Empty;

            // Determine What Products are in the Installer and their License Channels
            ProductListRetail retailList = new ProductListRetail();

            foreach (string productFolder in retailList.GetFolders())
            {
                if (Directory.Exists(InstallerPath + productFolder))
                {
                    RetailProducts.Add(retailList.GetProductName(productFolder));
                }
            }
            ProductListVolume volumeList = new ProductListVolume();

            foreach (string productFolder in volumeList.GetFolders())
            {
                if (Directory.Exists(InstallerPath + productFolder))
                {
                    VolumeProducts.Add(volumeList.GetProductName(productFolder));
                }
            }

            // Determine Installer Languages and Installer Architecture
            LanguageList languageList = new LanguageList();

            foreach (string languageCode in languageList.GetLanguageCodes())
            {
                if (Directory.Exists(InstallerPath + "Office64." + languageCode))
                {
                    Languages.Add(languageList.GetLanguageName(languageCode));
                    InstallerArchitecture = Architecture.X86;
                }
                else if (Directory.Exists(InstallerPath + "Office32." + languageCode))
                {
                    Languages.Add(languageList.GetLanguageName(languageCode));
                    InstallerArchitecture = Architecture.X64;
                }
            }

            // Get Microsoft Office Setup Version
            FileVersionInfo setupVersion = FileVersionInfo.GetVersionInfo(InstallerPath + "setup.exe");

            SetupVersionMajor = setupVersion.FileMajorPart;
            if (SetupVersionMajor <= 14)
            {
                // Microsoft Office 2010 and Older
                SetupVersionFull = setupVersion.FileVersion;
            }
            else
            {
                // Microsoft Office 2013 and Newer
                try
                {
                    FileVersionInfo setupDLLVersion = FileVersionInfo.GetVersionInfo(InstallerPath + "setup.dll");
                    SetupVersionFull = setupDLLVersion.FileVersion;
                }
                catch (FileNotFoundException)
                {
                    throw new ApplicationException("This is not a valid/supported Microsoft Office installer!");
                }
            }
        }