Exemplo n.º 1
0
        /// <summary>
        /// Method to get the product name
        /// </summary>
        /// <returns>Product name<returns>
        private string GetProductName()
        {
            string displayName = RegistryWrapper.GetValue(RegHive.LocalMachine, MSIInstallPropertiesRegPath, "DisplayName");

            return((displayName != null) ? Html.B(displayName) : null);
        }
Exemplo n.º 2
0
        public static string GetROHttpProperties()
        {
            StringBuilder output = new StringBuilder();

            output.Append(Html.br + Html.B("HTTP Properties > Advanced") + Html.br);

            try
            {
                string keyPath = @"Software\Mercury Interactive\Networking\Multi Settings\QTWeb\Recording";

                output.Append(CreateCheckBoxFromValue("Reset context for each action", keyPath, "ResetContextBetweenActions") + Html.br);
                output.Append(CreateCheckBoxFromValue("Save snapshots locally", keyPath, "SaveSnapshotResources") + Html.br);
                output.Append(CreateCheckBoxFromValue("Generate web_reg_find functions for page titles", keyPath, "RecordWebRegFind") + Html.br);
                output.Append(Html.IndentWithSpaces() + CreateCheckBoxFromValue("Generate web_reg_find functions for sub-frames", keyPath, "RecordWebRegFindNonPrimary") + Html.br);
                output.Append(CreateCheckBoxFromValue("Add comment to script for HTTP errors while recording", keyPath, "AddCommentsIfResponceBiggerThen400") + Html.br);
                output.Append((Html.IndentWithSpaces() + "Support charset") + Html.br);
                output.Append(Html.IndentWithSpaces() + CreateCheckBoxFromValue("Support charset UTF-8", keyPath, "Utf8Support") + Html.br);
                output.Append(Html.IndentWithSpaces() + CreateCheckBoxFromValue("Support charset EUC-JP", keyPath, "EUC Encode") + Html.br);
                //on LR < 11.5 this doesn't exist
                string ParameterizeServerNames = RegistryWrapper.GetRegKey32(RegHive.CurrentUser, @"Software\Mercury Interactive\Networking\Multi Settings\GlobalParameterizeServer\Recording", "ParameterizeServerNames");
                if (ParameterizeServerNames != null)
                {
                    output.Append(CreateCheckBoxFromValue("Parameterize server names", @"Software\Mercury Interactive\Networking\Multi Settings\GlobalParameterizeServer\Recording", "ParameterizeServerNames") + Html.br);
                }

                String file          = Path.Combine(ProductDetection.Vugen.ConfigFolder, "vugen.ini");
                String settingEngine = Html.ErrorMsg();

                if (File.Exists(file))
                {
                    IniParser vugenIni = new IniParser(file);
                    //Pre 12 versions:
                    if (ProductDetection.Vugen.version < new Version(12, 00))
                    {
                        string oldRecEngine = vugenIni.GetSetting("WebRecorder", "EnableOldSingleRecorded");
                        settingEngine = Html.CheckBox(oldRecEngine == "1") + "Record using earlier recording engine";

                        output.Append(Html.br + (Html.IndentWithSpaces() + "Recording engine: " + Html.br + Html.IndentWithSpaces() + settingEngine + Html.br));
                    }
                    else
                    {
                        string UseProxyRecorder  = vugenIni.GetSetting("WebRecorder", "UseProxyRecorder");
                        string ProxyInStreamMode = vugenIni.GetSetting("WebRecorder", "ProxyInStreamMode");

                        output.Append(Html.br + Html.IndentWithSpaces(4) + "Proxy Recording settings:" + Html.br);

                        output.Append(Html.CheckBox(UseProxyRecorder == "1", false, 8) + "Use the LoadRunner Proxy to record a local application" + Html.br);
                        output.Append(Html.CheckBox(ProxyInStreamMode == "1", false, 8) + "Use streaming mode when recording with the LoadRunner Proxy" + Html.br);
                    }
                }
                output.Append(Html.br + Html.IndentWithSpaces(4) + "Recording schemes: " + Html.br);
                string CustomHeadersKey = RegistryWrapper.GetValue(RegHive.CurrentUser, keyPath, "CustomHeaderFlag", "2");
                string headersMessage   = "Record headers <b>not</b> in the list";

                if (CustomHeadersKey == "1")
                {
                    headersMessage = "Record headers in the list";
                }
                else if (CustomHeadersKey == "0")
                {
                    headersMessage = "Do not record headers";
                }
                output.Append(Html.IndentWithSpaces(8) + "Headers: " + headersMessage + Html.br);

                if (CustomHeadersKey != "0")
                {
                    string headersKey = CustomHeadersKey == "2" ? "CustomHeadersExclude" : "CustomHeaders";
                    string headers    = RegistryWrapper.GetValue(RegHive.CurrentUser, keyPath, headersKey, "");
                    var    parts      = Regex.Split(headers, @"(?<=[01])").ToList();
                    parts.RemoveAll(item => item.EndsWith("0") || item.Equals(""));
                    output.Append(Html.IndentWithSpaces(12) + String.Join(Html.IndentWithSpaces(8), parts.ToArray()).Replace("\n1", Html.br).Replace("\n", Html.IndentWithSpaces(2)));
                }

                string ContentTypeFilterKey = RegistryWrapper.GetValue(RegHive.CurrentUser, keyPath, "ContentTypeFilterFlag", "0");
                var    contentMessage       = new Hashtable()
                {
                    { "0", "Do not filter content types" }, { "1", "Exclude content types in list:" }, { "2", "Exclude content types <b>not</b> in list:" }
                };
                output.Append(Html.br + Html.IndentWithSpaces(8) + "Content types: " + contentMessage[ContentTypeFilterKey] + Html.br);

                if (ContentTypeFilterKey != "0")
                {
                    string filtersKey = ContentTypeFilterKey == "2" ? "ContentTypeFilterExclude" : "ContentTypeFilter";
                    string content    = RegistryWrapper.GetValue(RegHive.CurrentUser, keyPath, filtersKey, "");

                    var parts = Regex.Split(content, @"(?<=[01])").ToList();
                    parts.RemoveAll(item => item.EndsWith("0") || item.Equals(""));
                    output.Append(Html.IndentWithSpaces(12) + String.Join(Html.IndentWithSpaces(8), parts.ToArray()).Replace("\n1", Html.br).Replace("\n", Html.IndentWithSpaces(2)));
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex.ToString());
                return(output + ex.Message);
            }
            return(output.ToString());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Method to get the product directory where the product is installed
        /// </summary>
        /// <returns></returns>
        private string GetInstallLocation()
        {
            string installLocation = RegistryWrapper.GetValue(RegHive.LocalMachine, MSIInstallPropertiesRegPath, "InstallLocation");

            return(installLocation);
        }
Exemplo n.º 4
0
            public string GetMaxConnectionTime()
            {
                string value = RegistryWrapper.GetRegKey64(RegHive.LocalMachine, icaTcpRegPath, "MaxConnectionTime");

                return((value == null) ? Html.ErrorMsg() : FormatSessionTimeout(value));
            }
Exemplo n.º 5
0
        /*
         * /// <summary>
         * /// Check if certain .net version is installed
         * /// </summary>
         * /// <param name="version">v3.5 | v4.0</param>
         * /// <returns></returns>
         * public bool IsDotNetVersionInstalled(string version)
         * {
         *  try
         *  {
         *      string path = (version == "v4") ? @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" : @"SOFTWARE\Microsoft\NET Framework Setup\NDP\" + version;
         *      string key = Registry.LocalMachine.OpenSubKey(path).GetValue("Install").ToString();
         *      return key == "1" ? true : false;
         *  }
         *  catch (Exception ex)
         *  {
         *      Logger.Error(ex.ToString());
         *      return false;
         *  }
         *
         * }*/

        #endregion

        #region SiteScope detection
        /// <summary>
        /// SiteScope DETECTION
        /// </summary>
        /// <returns></returns>
        public static string GetSiteScopeInfo()
        {
            try
            {
                Logger.Debug("GetSiteScopeInfo() started.");
                // check for installations of
                String[] siteScopeUpgradeCodes = new String[]
                {
                    "7C9790C8356D6A142B1E73F0AE4F22AB", //HP SiteScope for LoadTesting
                    "55D444412FEC9B349A920326911A26F1", //HP SiteScope Integrations
                    "F60D57E75AF65A84E888D007E2799EE9", //HP SiteScope Monitoring
                    "350F46B85A30F7240911CD2A1C293400", //HP SiteScope Server
                    "54509F95E83F79C43A15FDAFB2FF3CA3", //HP SiteScope User Interface
                    "CFCBC45A6F7CE934286FF54746AF7708"  //HP SiteScope Tools
                };

                // Get product codes for installed SiteScope features
                StringBuilder productInfo = new StringBuilder(1024);
                String        productCode = String.Empty;

                Stopwatch stopWatch = Stopwatch.StartNew();

                //if Parallel execution is enabled (default)
                if (FormArguments.async)
                {
                    Helper.EachParallel(siteScopeUpgradeCodes, upgradeCode =>
                    {
                        //foreach (string upgradeCode in siteScopeUpgradeCodes)
                        //{
                        productCode = ProductInfo.GetProductCode(upgradeCode);
                        if (productCode != null)
                        {
                            string registryPath = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\" + productCode + @"\InstallProperties";
                            //Logger.Log("Searching for SiteScope in registry path " + registryPath);
                            string productName = RegistryWrapper.GetValue(RegHive.LocalMachine, registryPath, "DisplayName");
                            Logger.Info("SiteScope product name " + productName);
                            // Product name found now find the product version
                            string productVersion = String.Empty;
                            if (productName != null)
                            {
                                productVersion = RegistryWrapper.GetValue(RegHive.LocalMachine, registryPath, "DisplayVersion");
                            }

                            string intallDate = RegistryWrapper.GetValue(RegHive.LocalMachine, registryPath, "InstallDate");
                            productInfo.Append(productName + ", version " + productVersion + " " + Helper.ConvertInstallDate(intallDate) + Html.br);
                        }
                    });
                }
                else
                {
                    foreach (string upgradeCode in siteScopeUpgradeCodes)
                    {
                        productCode = ProductInfo.GetProductCode(upgradeCode);
                        if (productCode != null)
                        {
                            string registryPath = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\" + productCode + @"\InstallProperties";
                            //Helper.Log("Searching for SiteScope in registry path " + registryPath);
                            string productName = RegistryWrapper.GetValue(RegHive.LocalMachine, registryPath, "DisplayName");
                            Logger.Info("SiteScope product name " + productName);
                            // Product name found now find the product version
                            string productVersion = String.Empty;
                            if (productName != null)
                            {
                                productVersion = RegistryWrapper.GetValue(RegHive.LocalMachine, registryPath, "DisplayVersion");
                            }

                            string intallDate = RegistryWrapper.GetValue(RegHive.LocalMachine, registryPath, "InstallDate");
                            productInfo.Append(productName + ", version " + productVersion + " " + Helper.ConvertInstallDate(intallDate) + Html.br);
                        }
                    }
                }

                TimeSpan ts = stopWatch.Elapsed;
                stopWatch.Stop();
                Logger.Debug("DetectOtherSoftware.GetProductCode finished. Execution time: " + ts.ToString());
                Debug.WriteLine(ts.ToString());

                return((productInfo.Length != 0) ? productInfo.ToString() : "No");
            }
            catch (Exception ex)
            {
                Logger.Error(ex.ToString());
                return(Html.ErrorMsg());
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Method to get the installation folder to JDK or JRE
        /// 1. Check 64bit registry
        /// </summary>
        /// <param name="product"></param>
        /// <param name="registryView">32 or 64</param>
        /// <returns></returns>
        private List <String> GetPathsToJava(string product, string registryView = null)
        {
            List <String> javaPaths = new List <string>();
            List <string> keys      = new List <string>();

            //String key = String.Empty;
            try
            {
                //search the 64bit registry (WOW6432Node) if we are on 64bit OS
                if (registryView == "64" && OSCollectorHelper.is64BitOperatingSystem)
                {
                    keys = RegistryWrapper.GetSubKeyNames(RegHive.LocalMachine, keyPath + product, RegSAM.WOW64_64Key);
                    if (keys != null)
                    {
                        Logger.Info("Found " + keys.Count + " keys in " + registryView + " registry " + keyPath);
                        foreach (string key in keys)
                        {
                            Logger.Info("Getting 'JavaHome' value from " + keyPath + product + "\\" + key);
                            javaPaths.Add(RegistryWrapper.GetRegKey64(RegHive.LocalMachine, keyPath + product + "\\" + key, "JavaHome"));
                        }
                    }
                    else
                    {
                        Logger.Info("No JAVA found in " + registryView + "bit registry " + keyPath + product);
                        return(null);
                    }
                }
                //search the 32bit registrys
                else if (registryView == "32")
                {
                    keys = RegistryWrapper.GetSubKeyNames(RegHive.LocalMachine, keyPath + product, RegSAM.WOW64_32Key);
                    if (keys != null)
                    {
                        Logger.Info("Found " + keys.Count + " keys in " + registryView + " registry " + keyPath);
                        foreach (string key in keys)
                        {
                            Logger.Info("Getting 'JavaHome' value from " + keyPath + product + "\\" + key);
                            javaPaths.Add(RegistryWrapper.GetRegKey32(RegHive.LocalMachine, keyPath + product + "\\" + key, "JavaHome"));
                        }
                    }
                    else
                    {
                        Logger.Info("No JAVA found in " + registryView + "bit registry " + keyPath + product);
                        return(null);
                    }
                }

                //remove the duplicate entries
                return(javaPaths.Distinct().ToList());
            }
            catch (NullReferenceException nre)
            {
                Logger.Info(nre.ToString());
                return(null);
            }
            catch (Exception ex)
            {
                Logger.Info(ex.ToString());
                return(null);
            }
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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);
        }