public static string getPatchesInstalled(string productCode) { //Helper.log("for product code " + productCode); try { string[] patchesCodes = LoadRunner.getPatchesCodes(productCode); string patchesInstalled = null; if (patchesCodes != null) { //Helper.log("Patches codes" + patchesCodes.ToString()); foreach (string patchCode in patchesCodes) { if (patchCode != "Patches") { string keyPath = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\" + productCode + @"\Patches\" + patchCode; Helper.Log("KeyPath to patch: " + keyPath); if (OSInfo.getOperatingSystemArchitecture().StartsWith("x86")) { RegistryKey rk = Registry.LocalMachine.OpenSubKey(keyPath); patchesInstalled += rk.GetValue("DisplayName").ToString() + " " + Helper.convertInstallDate(rk.GetValue("Installed").ToString()); } else { patchesInstalled += RegistryWOW6432.GetRegKey64(RegHive.HKEY_LOCAL_MACHINE, keyPath, "DisplayName") + " " + Helper.convertInstallDate(RegistryWOW6432.GetRegKey64(RegHive.HKEY_LOCAL_MACHINE, keyPath, "Installed")); } patchesInstalled += Html.br; } } return(patchesInstalled); } return("No patches were detected"); } catch (Exception ex) { return(Html.Error(ex.ToString())); } }
public static string isFullLRInstalled() { try { RegistryKey rk = Registry.ClassesRoot.OpenSubKey(@"\Installer"); if (rk != null) { Helper.Log("Number of keys in isntaller: " + rk.SubKeyCount.ToString()); } else { Helper.Log("Registry.ClassesRoot.OpenSubKey(\"Installer\") returned null!!!"); } //TODO check if the codes exists after uninstall string productCodeLR = Helper.getProductCode(LRUpdateCode); Helper.Log("LRUpdateCode: " + LRUpdateCode); Helper.Log("productCodeLR: " + productCodeLR); string productCodeLRPCHost = Helper.getProductCode(LRPCHostUpdateCode); Helper.Log("LRPCHostUpdateCode: " + LRPCHostUpdateCode); Helper.Log("productCodeLRPCHost: " + productCodeLRPCHost); string installDate = null; if (productCodeLR != null) { Helper.Log("productCodeLR: " + productCodeLR); string registryPath = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\" + productCodeLR + @"\InstallProperties"; //Helper.log("Registry path: " + registryPath); //installDate = Registry.LocalMachine.OpenSubKey(registryPath).GetValue("InstallDate").ToString(); //RegistryKey rk2 = Registry.LocalMachine.OpenSubKey(registryPath); installDate = RegistryWOW6432.GetRegKey64(RegHive.HKEY_LOCAL_MACHINE, registryPath, "InstallDate"); //Helper.log("Registry key InstallDate: " + installDate); //installDate = rk2.GetValue("InstallDate").ToString(); //installDate = rk2.GetValue("InstallerLocation").ToString(); //Helper.log("Install date: " + installDate); } if (productCodeLRPCHost != null) { string registryPath = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\" + productCodeLRPCHost + @"\InstallProperties"; installDate = RegistryWOW6432.GetRegKey64(RegHive.HKEY_LOCAL_MACHINE, registryPath, "InstallDate"); } return((productCodeLR != null || productCodeLRPCHost != null) ? "Yes " + Html.B(LoadRunner.getLRVersion()) + Helper.convertInstallDate(installDate) : Html.Warning("No")); } catch (Exception ex) { return(ex.ToString()); } }