I am trying to create a script that installs software on certain conditions. One of these conditions would be that the DisplayVersion in the Uninstall key in the registry is older than that of the new software.

These install strings have all kinds of formats. If it is just something like
"12.34.5678.0234"
it is not difficult to evaluate that
"13.00.0001.0001"
is more recent. just split with as delimiter the "." and evaluate the integer values in the array.

Here is a short piece of code that I got out of my script

Break ON

DIM $strUninstallRegPath, $strUninstallRegKey
DIM $strDisplayVersion, $arrDisplayVersion

$strUninstallRegPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
$strUninstallRegKey = "{8CAC1600-0BBE-499A-A9E9-5F334DBC8E89}"
$strDisplayVersion = "09.02.0100.1935"
$arrDisplayVersion = Split($strDisplayVersion, ".")

DIM $arrVersion
$arrVersion = Split(ReadValue($strUninstallRegPath + $strUninstallRegKey, "Displayversion"), ".")
If UBound($arrVersion) = UBound($arrDisplayVersion)
   
DIM $a
    For $a = 0 To UBound($arrDisplayVersion)
       
If CINT($arrDisplayVersion[$a]) > CINT($arrVersion[$a])
            fnInstallSoftware(
$strServer, $strPath, $strFile, $strSwitches)
           
Exit @ERROR
        EndIf
    Next
    Exit @ERROR
Else
    Exit 87
EndIf


But several kind of software have DisplayVersions like (just walking through my registry):
  • 6.00 H1
  • 1.4.2_06
  • 2.00 C3
  • 1.5.0.631.36.F

Does anybody know a smarter way to evaluate DisplayVersion strings?
Per example: "6.00 I0" would be more recent than "6.00 H1"
What would be a good way to evaluate this?