home *** CD-ROM | disk | FTP | other *** search
/ Minami 85 / MINAMI85.iso / Extra / QuickTimeInstaller.exe / RCDATA / CABINET / AppleSoftwareUpdate.msi / Binary.Scripts.vbs < prev    next >
Text File  |  2007-02-16  |  2KB  |  66 lines

  1. ' VBScript source code
  2. Option Explicit
  3.  
  4. ' Launch condition related subroutines-----------------------------------------
  5.  
  6. Function CompareVersions(sVersion1, sVersion2)
  7.     Dim rgExpVersionComponents
  8.     Dim oMatches1, oMatches2
  9.     Dim iVersion1, iVersion2
  10.     Dim i
  11.  
  12.     On Error Resume Next
  13.     Set rgExpVersionComponents = New RegExp
  14.     rgExpVersionComponents.Pattern = "(\d+)\.?"
  15.     rgExpVersionComponents.Global= True
  16.     Set oMatches1 = rgExpVersionComponents.Execute(sVersion1)
  17.     Set oMatches2 = rgExpVersionComponents.Execute(sVersion2)
  18.     i = 0
  19.     Do
  20.         Err.Clear
  21.         iVersion1 = 0
  22.         iVersion2 = 0
  23.         iVersion1 = CInt(oMatches1(i).SubMatches(0))
  24.         iVersion2 = CInt(oMatches2(i).SubMatches(0))
  25.         If iVersion1 < iVersion2 Then
  26.             CompareVersions = -1
  27.             Exit Function
  28.         ElseIf iVersion1 > iVersion2 Then
  29.             CompareVersions = 1
  30.             Exit Function
  31.         End If
  32.         i = i + 1
  33.     Loop While Err.number = 0
  34.     CompareVersions = 0
  35. End Function
  36.  
  37. Sub PreventDowngrade
  38.     Const msiInstallStateAdvertised = 1
  39.     Dim Installer
  40.     Dim RelatedProducts
  41.     Dim UpgradeCode
  42.     Dim ProductCode
  43.     Dim ProductVersion
  44.     Dim ProductVersionMax
  45.     Dim ProductVersionFound
  46.  
  47.     Set Installer = Session.Installer
  48.     ProductVersion = Session.Property("ProductVersion")
  49.     ProductVersionMax = ""
  50.     UpgradeCode = Session.Property("UpgradeCode")
  51.     Set RelatedProducts = Installer.RelatedProducts(UpgradeCode)
  52.     For Each ProductCode in RelatedProducts
  53.         If Installer.ProductState(ProductCode) = msiInstallStateAdvertised Then
  54.             ProductVersionFound = Installer.ProductInfo(ProductCode, "Version")
  55.         Else
  56.             ProductVersionFound = Installer.ProductInfo(ProductCode, "VersionString")
  57.         End If
  58.         If CompareVersions(ProductVersionFound, ProductVersionMax) > 0 Then ProductVersionMax = ProductVersionFound
  59.     Next
  60.     If CompareVersions(ProductVersionMax, ProductVersion) > 0 Then
  61.         Session.Property("BNEWERPRODUCTISINSTALLED") = "1"
  62.     Else
  63.         Session.Property("BNEWERPRODUCTISINSTALLED") = ""
  64.     End If
  65. End Sub
  66.