Hello I have made a patch for wpkg 1-rc8 so you can check nog only if a uninstall key exists but also what for version it is (with the DisplayVersion value).
I implemented the some comparison as the file version check. This is the first patch i made for wpkg so i hope i did it all correct. -- Greetings, Richard Thieme ICT Services t: +31-70-8903553 ... Caution: breathing may be hazardous to your health.
--- wpkg.js 2008-03-21 10:23:38.000000000 +0100 +++ wpkg-new.js 2008-03-21 12:02:52.000000000 +0100 @@ -806,6 +806,64 @@ function checkCondition(checkNode) { dinfo("Uninstall entry for " + checkPath + " missing: test failed"); return false; } + } else if (checkCond.substring(0,7) == "version") { + // Sanity check: Must have a value set for version check. + if (checkValue == null) { + throw new Error("Value is null for a uninstall version check. Perhaps " + + "a type? To help find it, here are the other pieces of information: " + + "condition='" + checkCond + "', path='" + checkPath + + "', value='" + checkValue + "'"); + } // if checkValue == null + + var CheckValFromUninstallSystem = getUninstallKeysVersion(checkPath); + var CheckValFromWpkg = checkValue; + if ((CheckValFromUninstallSystem == "UNKNOWN") || (CheckValFromUninstallSystem == "")) { + // Didn't get a sensible version number from GetUninstallVersion. + dinfo("Unable to find the uninstall version for " + checkPath); + return false; + } else { + var versionresult = versionCompare(CheckValFromUninstallSystem, + CheckValFromWpkg); + dinfo ("Checking uninstall version " + CheckValFromUninstallSystem + " is " + checkCond + + " (than) " + CheckValFromWpkg + " - got result "+versionresult); + switch (checkCond) { + case "versionsmallerthan": + retval=(versionresult == -1); + dinfo("Checking version of '"+checkPath+"' : Is "+CheckValFromUninstallSystem+ + " < "+checkValue+" ? "+retval); + return retval; + break; + case "versionlessorequal": + retval=( (versionresult == -1) + || (versionresult == 0) ); + dinfo("Checking version of '"+checkPath+"' : Is "+CheckValFromUninstallSystem+ + " <= "+checkValue+" ? "+retval); + return retval; + break; + case "versionequalto": + retval=(versionresult == 0); + dinfo("Checking version of '"+checkPath+"' : Is "+CheckValFromUninstallSystem+ + " = "+checkValue+" ? "+retval); + return retval; + break; + case "versiongreaterorequal": + retval=( (versionresult == 1) + || (versionresult == 0) ); + dinfo("Checking version of '"+checkPath+"' : Is "+CheckValFromUninstallSystem+ + " >= "+checkValue+" ? "+retval); + return retval; + break; + case "versiongreaterthan": + retval=(versionresult == 1); + dinfo("Checking version of '"+checkPath+"' : Is "+CheckValFromUninstallSystem+ + " >= "+checkValue+" ? "+retval); + return retval; + break; + default: + throw new Error("Unknown operation on uninstall versions : " + checkCond); + break; + } + } } else { throw new Error("Check condition " + checkCond + " unknown for " + "type uninstall."); @@ -5387,6 +5445,31 @@ function scanUninstallKeys(nameSearched) return false; } +function getUninstallKeysVersion(nameSearched) { + var scanKeys = new Array(); + scanKeys.push("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"); + if (is64bit()) { + // scan redirected path as well (assures that 32-bit applications are found) + scanKeys.push("SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall"); + } + for (var i=0; i < scanKeys.length; i++) { + var regPath = scanKeys[i]; + var keyNames = getRegistrySubkeys(regPath); + + for (var j=0; j < keyNames.length; j++) { + var displayName = getRegistryValue("HKLM\\" + regPath + "\\" + keyNames[j] + "\\DisplayName"); + + if (displayName != null) { + if (displayName == nameSearched) { + var displayVersion = getRegistryValue("HKLM\\" + regPath + "\\" + keyNames[j] + "\\DisplayVersion"); + return displayVersion; + } + } + } + } + return "UNKNOWN"; +} + /** * Scans the specified array for the specified element and returns true if * found.
------------------------------------------------------------------------- Do you use WPKG? Tell us how! >> http://wpkg.org/Testimonials _______________________________________________ wpkg-users mailing list wpkg-users@lists.wpkg.org http://lists.wpkg.org/mailman/listinfo/wpkg-users