예제 #1
0
        /// <summary>
        /// Returns true if given patch is uninstalled from all the target products
        /// </summary>
        /// <param name="patchCode"></param>
        /// <param name="targetProdCodes"></param>
        /// <returns></returns>
        public static bool IsPatchUninstalled(string patchCode, string[] targetProdCodes)
        {
            bool found = true;

            foreach (string targetProdCode in targetProdCodes)
            {
                // Exclude the patch verification for those products which are not installed
                if (!MsiUtils.IsProductInstalled(targetProdCode))
                {
                    continue;
                }

                foreach (PatchInstallation patch in PatchInstallation.GetPatches(patchCode, targetProdCode, null, UserContexts.All, PatchStates.All))
                {
                    if (patch.PatchCode == patchCode)
                    {
                        found = false;
                    }
                }

                // Return after first occurance of found. That is it will return false if patch is applied to any of the target products.
                if (!found)
                {
                    return(found);
                }
            }
            return(found);
        }
예제 #2
0
        public static string GetProperty(string msiPath, string property)
        {
            string propertyValue = null;

            if (!String.IsNullOrEmpty(msiPath))
            {
                msiPath = System.Environment.ExpandEnvironmentVariables(msiPath);
                Database db = new Database(msiPath);
                propertyValue = MsiUtils.GetProperty(db, property);
                db.Close();  // be sure to close the db or future attempts to open it will fail (i.e. to install/uninstall it)
            }
            return(propertyValue);
        }