Example #1
0
 public static string GetFirefoxInfo()
 {
     try
     {
         InstalledProgram firefox = InstalledProgramsHelper.GetInstalledProgramByName(new Regex("Firefox"));
         return(firefox == null ? "No" : "Yes, version " + firefox.DisplayVersion);
     }
     catch (Exception ex)
     {
         Logger.Error(ex.ToString());
         return(Html.ErrorMsg());
     }
 }
Example #2
0
 public static string GetGoogleChromeInfo()
 {
     try
     {
         InstalledProgram GoogleChrome = InstalledProgramsHelper.GetInstalledProgramByName("Google Chrome");
         return(GoogleChrome == null ? "No" : "Yes, version " + GoogleChrome.DisplayVersion);
     }
     catch (Exception ex)
     {
         Logger.Error(ex.ToString());
         return(Html.ErrorMsg());
     }
 }
Example #3
0
        static void GetShunraProductDetails(InstalledProgram p)
        {
            string currentVersion = RegistryWrapper.GetRegKey32(RegHive.LocalMachine, @"SOFTWARE\Shunra\Bootstrapper", "CurrentVersion");
            string buildVersion   = RegistryWrapper.GetRegKey32(RegHive.LocalMachine, @"SOFTWARE\Shunra\Bootstrapper", "BuildVersion");
            string installedPath  = RegistryWrapper.GetRegKey32(RegHive.LocalMachine, @"SOFTWARE\Shunra\Bootstrapper", "InstalledPath");

            productDetails = new StringBuilder();
            productDetails.Append(Html.B(p.DisplayName) + Helper.ConvertInstallDate(p.InstallDate) + Html.br);
            productDetails.Append("Version: " + currentVersion + Html.br);
            productDetails.Append("Build: " + buildVersion + Html.br);
            productDetails.Append("Location: " + installedPath + Html.br + Html.br);

            productDetails.Append("Services: " + Html.br);
            productDetails.Append("Shunra WatchDog Service: " + PCServicesCollectorHelper.GetServiceInfo("ShunraWatchDogService") + Html.br);
            productDetails.Append("Shunra Performance Counters Service: " + PCServicesCollectorHelper.GetServiceInfo("ShunraPerformanceCountersService") + Html.br);
        }
Example #4
0
        public static List <InstalledProgram> GetListOfInstalledPrograms()
        {
            string uninstallerKeyPath = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";

            //1. Get the products from 32bit Uninstaller @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
            installedProgramsList.AddProductsFromUninstallerKey(RegHive.LocalMachine, uninstallerKeyPath, RegSAM.WOW64_32Key);
            //count = installedProductsList.Count;
            //Logger.Debug(count + @" products found in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall");

            //2. Get the products from 64bit Uninstaller @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
            installedProgramsList.AddProductsFromUninstallerKey(RegHive.LocalMachine, uninstallerKeyPath, RegSAM.WOW64_64Key);
            //count = installedProductsList.Count - count;
            //Logger.Debug(count + @" products found in HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall");
            //count = installedProductsList.Count;

            //3. Get the products from HKEY_USERS\<user-sid>\Software\Microsoft\Windows\CurrentVersion\Uninstall
            string        keyPath  = @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList";
            List <string> userKeys = RegistryWrapper.GetSubKeyNames(RegHive.LocalMachine, keyPath, RegSAM.WOW64_64Key);

            Logger.Debug(userKeys.Count + " user keys found in " + keyPath);

            if (userKeys != null)
            {
                foreach (var userKey in userKeys)
                {
                    installedProgramsList.AddProductsFromUninstallerKey(RegHive.Users, userKey + "\\" + uninstallerKeyPath, RegSAM.WOW64_64Key);
                    count = installedProgramsList.Count - count;
                    Logger.Debug(count + " products found in HKEY_USERS\\" + userKey + "\\" + uninstallerKeyPath);
                    count = installedProgramsList.Count;
                }
            }

            //4. Get the products from "Software\Microsoft\Windows\CurrentVersion\Installer\UserData\<user-sid>\Products\<product-code>\InstallProperties"
            keyPath  = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData";
            userKeys = RegistryWrapper.GetSubKeyNames(RegHive.LocalMachine, keyPath, RegSAM.WOW64_64Key);
            if (userKeys != null)
            {
                foreach (var userKey in userKeys)
                {
                    if (userKey != "S-1-5-18")
                    {
                        //Get the products from i.e. "Software\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\<product-code>\InstallProperties"
                        keyPath = @"Software\Microsoft\Windows\CurrentVersion\Installer\UserData\" + userKey + @"\Products\";
                        List <string> productKeys = RegistryWrapper.GetSubKeyNames(RegHive.LocalMachine, keyPath, RegSAM.WOW64_64Key);
                        if (productKeys != null)
                        {
                            foreach (var productKey in productKeys)
                            {
                                string key             = keyPath + productKey + @"\InstallProperties";
                                string systemComponent = RegistryWrapper.GetRegKey(RegHive.LocalMachine, key, RegSAM.WOW64_64Key, "SystemComponent");
                                if (systemComponent != "1")
                                {
                                    string uninstallString = RegistryWrapper.GetRegKey(RegHive.LocalMachine, key, RegSAM.WOW64_64Key, "UninstallString");
                                    string displayName     = RegistryWrapper.GetRegKey(RegHive.LocalMachine, key, RegSAM.WOW64_64Key, "DisplayName");
                                    string displayVersion  = RegistryWrapper.GetRegKey(RegHive.LocalMachine, key, RegSAM.WOW64_64Key, "DisplayVersion");
                                    string installDate     = RegistryWrapper.GetRegKey(RegHive.LocalMachine, key, RegSAM.WOW64_64Key, "InstallDate");

                                    if (displayName != null && displayName != "")
                                    {
                                        var installedProduct = new InstalledProgram(displayName, displayVersion, uninstallString, installDate);
                                        if (!installedProgramsList.Contains(installedProduct))
                                        {
                                            installedProgramsList.Add(installedProduct);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    count = installedProgramsList.Count - count;
                    Logger.Debug(count + " products found in HKEY_LOCAL_MACHINE\\" + keyPath);
                    count = installedProgramsList.Count;
                }
            }
            // Add some logs for debugging
            if (Logger.level == (int)Logger.Level.DEBUG)
            {
                Logger.Debug("Products after Sort");
                int i = 1;
                foreach (var p in installedProgramsList)
                {
                    Logger.Debug(i + " " + p);
                    i++;
                }
            }
            return(installedProgramsList);
        }
Example #5
0
        /// <summary>
        /// Method to append the none-duplicated products from Uninstaller key
        /// We do this by iterating through the 64 and 32 bit Uninstall key @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
        /// and @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall".
        /// Ignore all SystemComponent key names that have value of 1
        /// Then we iterate through all user keys HKEY_USERS\user-sid\Software\Microsoft\Windows\CurrentVersion\Uninstall
        /// Then we add all none-duplicated products from @"Software\Microsoft\Windows\CurrentVersion\Installer\UserData\user-sid\Products\product-code\InstallProperties"
        /// </summary>
        /// <param name="tempInstalledProducts"></param>
        /// <param name="inHive"></param>
        /// <param name="uninstallerKeyPath"></param>
        /// <param name="in64or32key"></param>
        /// <returns></returns>
        public static List <InstalledProgram> AddProductsFromUninstallerKey(this List <InstalledProgram> tempInstalledProducts, UIntPtr inHive, string uninstallerKeyPath, RegSAM in64or32key)
        {
            var regex        = new Regex("KB[0-9]{5,7}$");
            int updatesCount = 0;

            List <string> subkeyNames = RegistryWrapper.GetSubKeyNames(inHive, uninstallerKeyPath, in64or32key);

            if (subkeyNames != null)
            {
                foreach (var subkeyName in subkeyNames)
                {
                    // Check only keys like {CFEF48A8-BFB8-3EAC-8BA5-DE4F8AA267CE}
                    // but not {CFEF48A8-BFB8-3EAC-8BA5-DE4F8AA267CE}.KB2504637 which are updates
                    if (!regex.Match(subkeyName).Success)
                    {
                        string SystemComponent = RegistryWrapper.GetRegKey(inHive, uninstallerKeyPath + "\\" + subkeyName, in64or32key, "SystemComponent");
                        if (SystemComponent != "1")
                        {
                            string Windowsinstaller = RegistryWrapper.GetRegKey(inHive, uninstallerKeyPath + "\\" + subkeyName, in64or32key, "Windowsinstaller");
                            if (Windowsinstaller != "1")
                            {
                                //Make sure we are not dealing with a patch or an update
                                string releaseType   = RegistryWrapper.GetRegKey(inHive, uninstallerKeyPath + "\\" + subkeyName, in64or32key, "ReleaseType");
                                string parentKeyName = RegistryWrapper.GetRegKey(inHive, uninstallerKeyPath + "\\" + subkeyName, in64or32key, "ParentKeyName");

                                if (parentKeyName != null)
                                {
                                    if (parentKeyName != "" || releaseType == "Security Update" || releaseType == "Update Rollup" || releaseType == "Hotfix")
                                    {
                                        updatesCount++;
                                    }
                                }

                                if (parentKeyName == null)
                                {
                                    string uninstallString = RegistryWrapper.GetRegKey(inHive, uninstallerKeyPath + "\\" + subkeyName, in64or32key, "UninstallString");
                                    if (uninstallString != null)
                                    {
                                        string displayName    = RegistryWrapper.GetRegKey(inHive, uninstallerKeyPath + "\\" + subkeyName, in64or32key, "DisplayName");
                                        string displayVersion = RegistryWrapper.GetRegKey(inHive, uninstallerKeyPath + "\\" + subkeyName, in64or32key, "DisplayVersion");
                                        string installDate    = RegistryWrapper.GetRegKey(inHive, uninstallerKeyPath + "\\" + subkeyName, in64or32key, "InstallDate");

                                        if (displayName != null && displayName != "")
                                        {
                                            var product = new InstalledProgram(displayName, displayVersion, uninstallString, installDate);
                                            if (!tempInstalledProducts.Contains(product))
                                            {
                                                tempInstalledProducts.Add(product);
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                string productId   = GetInstallerKeyNameFromGuid(subkeyName);
                                string productKey  = @"Software\Classes\Installer\Products\" + productId;
                                string productName = RegistryWrapper.GetRegKey(inHive, productKey, RegSAM.WOW64_64Key, "ProductName");
                                if (productName != null)
                                {
                                    string displayVersion  = RegistryWrapper.GetRegKey(inHive, uninstallerKeyPath + "\\" + subkeyName, in64or32key, "DisplayVersion");
                                    string uninstallString = RegistryWrapper.GetRegKey(inHive, uninstallerKeyPath + "\\" + subkeyName, in64or32key, "UninstallString");
                                    string installDate     = RegistryWrapper.GetRegKey(inHive, uninstallerKeyPath + "\\" + subkeyName, in64or32key, "InstallDate");

                                    var product = new InstalledProgram(productName, displayVersion, uninstallString, installDate);
                                    if (!tempInstalledProducts.Contains(product))
                                    {
                                        tempInstalledProducts.Add(product);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(tempInstalledProducts);
        }